<html>
<head>
</head>
<body style="background: transparent;">
    <script src="scripts/docstrap.lib.js"></script>
    <script src="scripts/lunr.min.js"></script>
    <script src="scripts/fulltext-search.js"></script>

    <script type="text/x-docstrap-searchdb">
    {"shield.util.js.html":{"id":"shield.util.js.html","title":"Source: shield.util.js","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Source: shield.util.js /*工具*/ ;(function($){ /** * 序列表单内容为json对象 * @constructor $().serializeJson * @author kevin Lv * @returns {Json} json对象 * @example $(\"form\").serializeJson() * */ $.fn.serializeJson = function(){ var serializeObj = {}; var array = this.serializeArray(); var str = this.serialize(); $(array).each(function(){ if(serializeObj[this.name] || serializeObj[this.name]===\"\"){ //空字符串会处理为null if($.isArray(serializeObj[this.name])){ serializeObj[this.name].push(this.value); } else { serializeObj[this.name] = [serializeObj[this.name],this.value]; } }else{ serializeObj[this.name] = this.value; } }); return serializeObj; }; /** * 动态监听内容变化 * @constructor $().contentChange * @author kevin Lv * @param selector {String} jQuery选择器 * @param callbackFn {Function} 回调函数 * @example $(\"body\").contentChange(\"body\", function(){}); * */ $.fn.contentChange= function(selector, callbackFn){ /** * @description 处理函数 */ this.each(function(){ var containerE = $(this); containerE.on('DOMNodeInserted', selector, function(){ //ie8以上支持 callbackFn($(this)); }); }); }; })(jQuery); /** * resize增强版（默认只有浏览器窗口调整大小，修改后可监听div或其它元素） * @constructor $().resize * @author 来自网络 * @param callbackFn {Function} 回调函数 * @example $(\"#div1\").resize(function(){}); * */ ;(function($, h, c) { var a = $([]), e = $.resize = $.extend($.resize, {}), i, k = \"setTimeout\", j = \"resize\", d = j + \"-special-event\", b = \"delay\", f = \"throttleWindow\"; e[b] = 350; e[f] = true; $.event.special[j] = { setup : function() { if (!e[f] &amp;&amp; this[k]) { return false } var l = $(this); a = a.add(l); $.data(this, d, { w : l.width(), h : l.height() }); if (a.length === 1) { g() } }, teardown : function() { if (!e[f] &amp;&amp; this[k]) { return false } var l = $(this); a = a.not(l); l.removeData(d); if (!a.length) { clearTimeout(i) } }, add : function(l) { if (!e[f] &amp;&amp; this[k]) { return false } var n; function m(s, o, p) { var q = $(this), r = $.data(this, d); r.w = o !== c ? o : q.width(); r.h = p !== c ? p : q.height(); n.apply(this, arguments) } if ($.isFunction(l)) { n = l; return m } else { n = l.handler; l.handler = m } } }; function g() { i = h[k](function() { a.each(function() { var n = $(this), m = n.width(), l = n.height(), o = $ .data(this, d); if (m !== o.w || l !== o.h) { n.trigger(j, [ o.w = m, o.h = l ]) } }); g() }, e[b]) } })(jQuery, this); /** * 将值插入到光标位置 * @constructor $().insertAtCursor * @author 来自网络 * @param myValue {String} 赋值 * @example $(\"#div1\").insertAtCursor('123'); * */ $.fn.extend({ insertAtCursor : function(myValue) { var $t = $(this)[0]; if (document.selection) { this.focus(); sel = document.selection.createRange(); sel.text = myValue; this.focus(); } else if ($t.selectionStart || $t.selectionStart == '0') { var startPos = $t.selectionStart; var endPos = $t.selectionEnd; var scrollTop = $t.scrollTop; $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length); this.focus(); $t.selectionStart = startPos + myValue.length; $t.selectionEnd = startPos + myValue.length; $t.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } } }); /** * 获取选中元素对象（对象中包含开始位置、结束位置、内容） * @constructor $().selection * @author 来自网络 * @example $(\"#div1\").selection().text; * */ $.fn.selection = function(){ var s,e,range,stored_range; if (this[0].selectionStart == undefined) { var selection=document.selection; if (this[0].tagName.toLowerCase() != \"textarea\") { var val = this.val(); range = selection.createRange().duplicate(); range.moveEnd(\"character\", val.length); s = (range.text == \"\" ? val.length:val.lastIndexOf(range.text)); range = selection.createRange().duplicate(); range.moveStart(\"character\", -val.length); e = range.text.length; } else { range = selection.createRange(), stored_range = range.duplicate(); stored_range.moveToElementText(this[0]); stored_range.setEndPoint('EndToEnd', range); s = stored_range.text.length - range.text.length; e = s + range.text.length; } } else { s=this[0].selectionStart, e=this[0].selectionEnd; } var te=this[0].value.substring(s,e); return {start:s, end:e, text:te}; }; /** * Map对象 * @constructor Map * @author kevin Lv * @example 示例： * var myMap = new Map(); * myMap.put(\"key\",\"value\"); * var key = myMap.get(\"key\"); * myMap.remove(\"key\"); * */ function Map(){ this.elements = new Array(); this.size = function(){ return this.elements.length; } this.isEmpty = function(){ return (this.elements.length &lt; 1); } this.clear = function(){ this.elements = new Array(); } this.put = function(_key, _value){ this.remove(_key); this.elements.push({key: _key, value: _value}); } this.remove = function(_key){ try { for (i = 0; i &lt; this.elements.length; i++) { if (this.elements[i].key == _key) { this.elements.splice(i, 1); return true; } } } catch (e) { return false; } return false; } this.get = function(_key){ try { for (i = 0; i &lt; this.elements.length; i++) { if (this.elements[i].key == _key) { return this.elements[i].value; } } } catch (e) { return null; } } this.element = function(_index){ if (_index &lt; 0 || _index &gt;= this.elements.length) { return null; } return this.elements[_index]; } this.containsKey = function(_key){ try { for (i = 0; i &lt; this.elements.length; i++) { if (this.elements[i].key == _key) { return true; } } } catch (e) { return false; } return false; } this.values = function(){ var arr = new Array(); for (i = 0; i &lt; this.elements.length; i++) { arr.push(this.elements[i].value); } return arr; } this.keys = function(){ var arr = new Array(); for (i = 0; i &lt; this.elements.length; i++) { arr.push(this.elements[i].key); } return arr; } } /** * Dialog对象 * @constructor Dialog * @author kevin Lv * @example 示例： * var dialog = new Dialog(); * dialog.put(ele, index, width, height, preEle, preEleIndex); * */ function Dialog(){ /** 弹出框元素对象 @type jQueryObject */ this.ele = {}; /** 下标 @type int */ this.index = -1; /** 宽度 @type int */ this.width = 0; /** 高度 @type int */ this.height = 0; /** 上一个弹出框元素下标 @type jQueryObject */ this.preEleIndex = null; /** 上一个弹出框元素 @type jQueryObject */ this.preEle = null; /** 标题 @type String */ this.title = \"\"; this.init = function (ele, index, width, height, preEle, preEleIndex){ ele.data(\"index\", index); this.ele = ele; if (index) { this.index = index; } if (width) { this.width = width; } else { this.width = ele.width(); } if (height) { this.height = height; } else { this.height = ele.height(); } if (preEleIndex) { this.preEleIndex = preEleIndex; } this.preEle = preEle; } } /** * 根据传入字符串返回jQuery对象，如果本身为jquery对象直接返回 * @param selector {Object} jQuery对象或者jQuery选择器 * @returns {jQueryObject} jQuery对象 */ function getjQueryObj(selector){ if (selector) { if(!(selector instanceof jQuery)){ selector = $(selector); } } return jQObjEmpty2Null(selector); } /** * 是否存在属性 * @param jobj {jQueryObject} 判断的对象 * @param attrname {String} 属性名 * @returns {Boolean} 存在该属性则返回true，否则返回false */ function hasAttr(jobj, attrname){ if(!jobj){ return false; } return typeof(jobj.attr(attrname))!=\"undefined\"; } /** * 获取一个jQuery对象的扩展设置（取属性shieldSettings的设置值覆盖，不存在则取jQuery.data()设置的属性，） * @param ele {jQueryObject} 待处理的对象 * @param _default {Json} 默认设置 * @returns {Json} 参数设置 */ function getExtendSettings(ele, _default){ _default = _default||{}; var settings = getParams(ele, {}, \"shieldSettings\"); return $.extend(true, _default, ele.data(), settings); }; /** * 获取一个jQuery对象的设置（取属性shieldSettings的设置值） * @param ele {jQueryObject} 待处理的对象 * @param _default {Json} 默认设置 * @returns {Json} 参数设置 */ function getSettings(ele, _default){ var settings = getParams(ele, _default||{}, \"shieldSettings\"); return settings; }; /** * 获取参数 * @param ele {jQueryObject} 待处理的对象 * @param params {Json} 默认设置 * @param attrName {String} 属性名 * @returns {Json} 参数设置 */ function getParams(ele, params, attrName){ try { if (!attrName) { attrName = \"shieldParams\"; } if (hasAttr(ele, attrName)) { //有参数时从shieldParams取 params = $.metadata ? $.extend({}, params, ele.metadata({ \"type\": \"attr\",\"name\": attrName, \"single\":attrName })) : params; } else { //无参数时默认从class取 params = $.metadata ? $.extend({}, params, ele.metadata()) : params; } return params; } catch (e) { var name = ele.attr(\"name\"); if (!name) { name = ele.val(); } alert(\"获取参数异常：\"+name+\" \"+e); return false; } }; /** * 获取时间参数，转换为毫秒 * @param ele {jQueryObject} 待处理的对象 * @param attrName {String} 属性名 * @param defaultValue {Number} 默认值 * @returns {Number} 时间值 */ function getTimeAttr(ele, attrName, defaultValue){ var time = defaultValue; if (hasAttr(ele, attrName)) { var timeSrc = ele.attr(attrName).toLowerCase(); var time = parseFloat(timeSrc); time = time*1000; //默认是秒 if (timeSrc.indexOf(\"m\") != -1 || timeSrc.indexOf(\"min\") != -1) { time = time*60; //分钟，1min=60s } if (timeSrc.indexOf(\"h\") != -1 || timeSrc.indexOf(\"hour\") != -1) { time = time*3600; //小时，1h=3600s } } return time; }; /** * 全部替换，默认替换只替换第1个 * @constructor String.replaceAll * @param s1 {String} 替换前字符串 * @param s2 {String} 替换后字符串 * @returns {String} */ String.prototype.replaceAll = function(s1, s2){ //gm g=global, m=multiLine return this.replace(new RegExp(s1,\"gm\"),s2); } /** * 获取并标记获取到的元素，防止重复添加 * @param ele {jQueryObject} 待处理的父对象 * @param selector {String} 选择器 * @see {@link findEle} 注意区别 * @returns {jQueryObject} */ function findAndMarkEle(ele, selector) { var markSelector = selector.replaceAll(\" \",\"\").replaceAll(\"\\\\.\",\"_\").replaceAll(\"#\",\"_sdc01_\").replaceAll(\"\\\\:\",\"_sdc02_\").replaceAll(\"&gt;\",\"_sdc03_\") .replaceAll(\"\\\\+\",\"_sdc04_\").replaceAll(\"\\\\~\",\"_sdc05_\").replaceAll(\"=\",\"_sdc06_\").replaceAll(\"\\\\!\",\"_sdc07_\").replaceAll(\"\\\\^\",\"_sdc08_\") .replaceAll(\"\\\\$\",\"_sdc09_\").replaceAll(\"\\\\*\",\"_sdc10_\").replaceAll(\"\\\\[\",\"_sdc11_\").replaceAll(\"\\\\]\",\"_sdc12_\").replaceAll(\"\\\\(\",\"_sdc13_\") .replaceAll(\"\\\\)\",\"_sdc14_\").replaceAll(\"'\",\"_sdc15_\").replaceAll(\"\\\"\",\"_sdc16_\").replaceAll(\",\",\"_sdc17_\"); // var ele = ele.find(selector + \":not(.shieldMarked\"+markSelector+\",.noshield)\"); //此写法在selector为多重选择器时有问题，如弹出框.shieldDialog,.shieldLookup var ele = ele.find(selector).not(\".shieldMarked\"+markSelector+\",.noshield\"); ele.addClass(\"shieldMarked\"+markSelector); ele.data(\"shieldMarked\"+markSelector, \"marked\"); return ele; }; // /** * 获取但不标记取到的元素 * @param ele {jQueryObject} 待处理的父对象 * @param selector {String} 选择器 * @see {@link findAndMarkEle} 注意区别 * @see {@link findAndMarkEleOn} 注意区别 * @returns {jQueryObject} */ function findEle(ele, selector) { var ele = ele.find(selector + \":not(.noshield)\"); return ele; }; /** * 获取并标记元素，动态绑定事件(待完善) * @param ele {jQueryObject} 待处理的父对象 * @param selector {String} 一个选择器字符串用于过滤器的触发事件的选择器元素的后代。如果选择的为null或省略，当它到达选定的元素，事件总是触发。 * @param events {String} 一个或多个用空格分隔的事件类型和可选的命名空间，如\"click\"或\"keydown.myPlugin\" 。 * @see {@link findAndMarkEle} 注意区别 * @returns {jQueryObject} */ function findAndMarkEleOn(ele, selector, events) { var ele = findAndMarkEle(ele, selector); ele.off(events, selector).on(events, selector, function(event){ var shieldForwardEle = $(this); if (hasAttr(shieldForwardEle,\"toShieldMenu\")) { //有菜单属性才处理 var toShieldMenuArr = shieldForwardEle.attr(\"toShieldMenu\").split(\"&gt;\"); if (toShieldMenuArr.length &gt; 1) { var toNavMenu = $(toShieldMenuArr[0]); shieldForwardEle.attr(\"showclass\",toShieldMenuArr[1]); //添加属性，跳转完成后移除 toNavMenu.click(); } } }); return ele; }; /** * 格式化url，处理为标准格式的url * @param url {String} 待处理的url * @returns {String} */ var formatUrl = function(url) { if (!url || url == '/') { return ''; } if (url.indexOf('http://') == 0 || url.indexOf('https://') == 0) { return url; } if(url.indexOf('/') == 0){ //本地路径 return url; }else{ return 'http://' + url; } }; /** * 打开新页面 * @param ele {jQueryObject} 待处理的对象 * @param href {String} 超链接 * @param params {Json} 参数 */ var openNewPage = function(ele, href, params) { var formEs = ele.closest(\"form\"); if (formEs.length &gt; 0) { ele = formEs; //包含在form内时需要插入到form外部，否则提交的是父form } var html = \"&lt;form action='\" + href + \"' target='_blank' method='POST'&gt;\"; for(var key in params){ if($.isArray(params[key])){ for(var i=0;i&lt;params[key].length;i++) { html += \"&lt;input type='hidden' name='\" + key + \"' value='\" + params[key][i] + \"'&gt;\"; //直接取是逗号连接的字符串 } } else { html += \"&lt;input type='hidden' name='\" + key + \"' value='\" + params[key] + \"'&gt;\"; } } html+= \"&lt;/form&gt;\"; ele.after(html); var formE = ele.next(); formE.submit(function(){ return true; }).submit(); //直接用a.click()不执行 formE.remove(); } /** * 替换指定传入参数的值, paramName为参数, replaceWith为新值 * @param oUrl {String} 待处理的url * @param paramName {String} 处理参数 * @param replaceWith {String} 参数处理后的值 * @returns {String} */ function replaceParamVal(oUrl, paramName, replaceWith) { var re = eval('/('+ paramName+'=)([^&amp;]*)/gi'); var nUrl = oUrl.replace(re, paramName+'='+replaceWith); return nUrl; } /** * 日期格式化（待删除，改为moment.js） * @param date {Date} 带格式话的日期 * @param format {String} 格式化的表达式，如：yyyy-MM-dd * @returns {String} */ var dateFormat = function(date, format) { if (format === undefined) { format = date; date = new Date(); } var map = { \"M\" : date.getMonth() + 1, // 月份 \"d\" : date.getDate(), // 日 \"H\" : date.getHours(), // 小时 \"h\" : date.getHours(), // 小时 \"m\" : date.getMinutes(), // 分 \"s\" : date.getSeconds(), // 秒 \"q\" : Math.floor((date.getMonth() + 3) / 3), // 季度 \"S\" : date.getMilliseconds() // 毫秒 }; format = format.replace(/([yMdHhmsqS])+/g, function(all, t) { var v = map[t]; if (v !== undefined) { if (all.length &gt; 1) { v = '0' + v; v = v.substr(v.length - 2); } return v; } else if (t === 'y') { return (date.getFullYear() + '').substr(4 - all.length); } return all; }); return format; }; /** * 参数名适配,返回json格式，键为源字段名值为目标字段名 * @param ele {jQueryObject} 待处理的对象 * @returns {Map} */ var paramNameAdapt = function(ele) { var paramAdapter = ele.attr(\"paramAdapter\"); var params = {}; if (paramAdapter) { //有值且不为空 //paramAdapter=\"id&gt;typeId#newsType\" var paramAdapters = paramAdapter.split(\"#\"); //#号分隔 for(var i=0;i&lt;paramAdapters.length;i++){ var paramName = paramAdapters[i]; if (paramName.indexOf(\"&gt;\")!=-1) { var paramNames = paramName.split(\"&gt;\"); //如果key与提交不一致用&gt;号分隔 var sourceName = paramNames[0]; var targetName = paramNames[1]; params[sourceName] = targetName; } else { params[paramName] = paramName; } } } return params; } /** * 判断jquery空对象转换为null，其他的原样返回 * @param ele {jQueryObject} 待处理的对象 * @returns {jQueryObject} */ var jQObjEmpty2Null = function(ele) { if (!ele || ele.length == 0) { return null; } return ele; } /** * 移除字符串中的html字符 * @param str {String} 待处理的字符 * @returns {String} */ var removeHtml = function(str) { return jQuery(\"&lt;p&gt;\"+str+\"&lt;/p&gt;\").text(); } /** * 随机取色 * @returns {String} 16进制表示的颜色字符串 */ var getRandomColor = function(){ return '#' + (function(color){ return (color += '0123456789abcdef'[Math.floor(Math.random()*16)]) &amp;&amp; (color.length == 6) ? color : arguments.callee(color); })(''); } /** * 打印堆栈信息 * @returns {String} */ function printCallStack() { var stackStr = \"\"; if (console &amp;&amp; console.trace){ //ie8下不支持trace console.trace(); } return stackStr; } /** * 返回当前js的路径 * @returns {String} */ function getJSPath(){ var currentScript=document.currentScript?document.currentScript.src:function(){ var jssrc; var jss=document.scripts; for(var i=jss.length-1,n=i;n&gt;0;n--){ alert(1); if(\"interactive\"===jss[n].readyState){ //已经加载 jssrc=jss[n].src; break; } return jssrc||jss[i].src } }(); return currentScript; } /** * 返回当前js的目录 * @returns {String} */ function getJSDir(){ var jsPath = getJSPath(); return jsPath.substring(0,jsPath.lastIndexOf(\"/\")+1) } //ie8不支持isArray的方法 if (!Array.isArray) { Array.isArray = function(arg) { return Object.prototype.toString.call(arg) === '[object Array]'; }; } × Search results Close "},"shield.core.js.html":{"id":"shield.core.js.html","title":"Source: shield.core.js","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Source: shield.core.js ;(function($){ /** * 主函数，可直接调用，建议通过ShieldJS.init调用 * @author 吕凯 * @param {json} options - 配置参数{@link ShieldJS.core._defaults} * */ ShieldJS.core.main = function(options){ for(var optionKey in options){ if(!_defaults[optionKey]) { ShieldJS.error(\"参数\"+optionKey+\"不存在，请检查是否配置正确！\"); } } ShieldJS.core.options = $.extend({},_defaults, options); getPageFrameEle(ShieldJS.core.options); //页面框架元素获取 //通用化 $(\"body\").shieldBindHtmlAction(); //初始化页面内容 ShieldJS.core.initMainPage(ShieldJS.topBarE, ShieldJS.topMenuE); }; /** * 初始化之后的参数 * @author 吕凯 * @type {json} * */ ShieldJS.core.options = {}; //----------------------------------------------------------------------------- //-------------------------------以下为公开方法--------------------------------- //----------------------------------------------------------------------------- /** * 绑定Html动作处理 * @author 吕凯 * @param {Array} methodNames - 调用方法名，字符串数组，【非必需】，不写则调用全部方法 * @param {jQueryObject} contentE - 内容dom【必需】jQuery对象 * @param {jQueryObject} menuliSelectE - 左侧栏选中的menu【非必需】jQuery对象 * @param {jQueryObject} topMenuSelectE - 导航栏选中的menu【非必需】jQuery对象 * @param {jQueryObject} searchForm -搜索表单【非必需】jQuery对象 * @param {ShieldJS.dialog} shieldDialog - 弹出框对象【非必需】shieldDialog对象 */ ShieldJS.core.bindHtmlAction = function(methodNames, contentE, menuliSelectE, topMenuSelectE, searchForm, shieldDialog){ var methodNames = arguments[0]; if (!$.isArray(methodNames)) { //未指定调用方法 shieldDialog = arguments[4]; searchForm = arguments[3]; topMenuSelectE = arguments[2]; menuliSelectE = arguments[1]; contentE = arguments[0]; methodNames = null; } var actions = $.extend({},ShieldJS.HtmlAction.HTMLEleActions); var options = ShieldJS.core.options; var foreachObj = actions; //获取html元素action处理 if (methodNames) { foreachObj = methodNames; } var hasError = false; var bindBeforeCallbackE = findAndMarkEle(contentE, '[bindBefore]'); //绑定前处理 if (bindBeforeCallbackE.length &gt; 0) { // 有搜索表单时的处理(class=\"searchForm\") var callbackFn = bindBeforeCallbackE.attr(\"bindBefore\"); callbackFn = eval(callbackFn); //字符串转换为方法 if ($.isFunction(callbackFn)) { callbackFn(bindBeforeCallbackE); //需要自定义 } } for(var actionName in foreachObj){ if (methodNames) { actionName = foreachObj[actionName]; //数组返回的下标 } try { // 无checkFn函数的直接调用 if (!$.isFunction(actions[actionName].checkFn)) { actions[actionName].fn(contentE, menuliSelectE, topMenuSelectE, searchForm, shieldDialog); } else if ($.isFunction(actions[actionName].checkFn)) { // 有checkFn函数的检测完后调用 var ele = actions[actionName].checkFn(contentE, menuliSelectE, topMenuSelectE, searchForm, shieldDialog); if (ele) { actions[actionName].fn(ele, menuliSelectE, topMenuSelectE, searchForm, shieldDialog); } } } catch (e) { hasError = true; ShieldJS.debug(\"方法出错！\") ShieldJS.alert(\"消息提示\", \"方法异常：\"+actionName+\" \"+e, \"error\"); if(options &amp;&amp; $.isFunction(options.bindHtmlErrorCallback) ){ //成功错误回调函数 options.bindHtmlErrorCallback(actionName, e); } break; // return false; } } var bindAfterCallbackE = findAndMarkEle(contentE, '[bindAfter]'); //绑定后处理 if (bindAfterCallbackE.length &gt; 0) { // 自定义回调处理 var callbackFn = bindAfterCallbackE.attr(\"bindAfter\"); callbackFn = eval(callbackFn); //字符串转换为方法 if ($.isFunction(callbackFn)) { callbackFn(bindAfterCallbackE); //需要自定义 } } if(!hasError &amp;&amp; options &amp;&amp; $.isFunction(options.bindHtmlSuccCallback) ){ //成功回调函数 options.bindHtmlSuccCallback(); } if(options &amp;&amp; $.isFunction(options.bindHtmlCallback) ){ //回调函数 options.bindHtmlCallback(); } }; /** * 页面框架化处理：：：处理整个内容区 * @author 吕凯 * @param {jQueryObject} contentE - 内容dom【必需】（以下均为jquery对象） * @param {jQueryObject} siderMenuClickEle - 左侧栏选中的menu【非必需】 * @param {jQueryObject} topMenuSelectE - 头部导航栏选中的menu【非必需】 */ ShieldJS.core.contentAreaDeal = function(contentE, siderMenuClickEle, topMenuClickEle){ var comPeriodContentE = findAndMarkEle(contentE, '.shieldTabContent'); //多页签处理 if (comPeriodContentE.length &gt; 0) {//多页签处理 var shieldHeader = contentE.find('.shieldHeader'); shieldAClickFn(comPeriodContentE, shieldHeader, siderMenuClickEle, topMenuClickEle); } else { //普通页签 contentWithSubmitDeal(contentE, siderMenuClickEle, topMenuClickEle); } return true; }; /** * 页面框架化处理：：：主页面操作 默认实现如果不满足实际使用可以覆盖对应的方法 * @param topBarE {jQueryObject} 头部bar，用于与内容页的交互跳转 * @param topMenuE {jQueryObject} 头部菜单 */ ShieldJS.core.initMainPage = function(topBarE, topMenuE){ if(!topMenuE){ topMenuE = $(\"#navMenu\"); } var topMenus = findAndMarkEle(topMenuE, \".menu\") topMenus.click(function(event, doClick){ //doclick我传参 doClick = doClick||'true'; //是否执行点击，默认true var topMenuClickEle = $(this); //头部导航栏选中 ShieldJS.activeTopMenuE = topMenuClickEle; if (hasAttr(topMenuClickEle, \"clickExtendFn\")) { //自身的扩展点击事件，返回false则不执行原方法，返回true则继续原方法 var clickExtendFnName = topMenuClickEle.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(event, topMenuClickEle, topMenuE, contentE)){ return false; } } } else if (hasAttr(topMenuE, \"clickExtendFn\")) { //父类的扩展点击事件，建议直接绑定到父类，方便管理 var clickExtendFnName = topMenuE.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(event, topMenuClickEle, topMenuE, contentE)){ return false; } } } topMenuE.find(\".menu\").removeClass(ShieldJS.core.options.navMenuCurClass); topMenuClickEle.addClass(ShieldJS.core.options.navMenuCurClass); var url = topMenuClickEle.data(\"url\"); if (topMenuClickEle.data(\"url\")) { ShieldJS.ajax.get(ShieldJS.siderE, url, {}, function(){ ShieldJS.core.bindHtmlAction(ShieldJS.siderE); //初始化左侧栏内容 ShieldJS.core.initLeftMenu(ShieldJS.siderE, topBarE, topMenuClickEle, true); }); } else { //无url var noUrlMenuEles = topMenuE.find(\".menu:not([data-url])\"); var menuIndex = noUrlMenuEles.index(topMenuClickEle); var liMenuContainerE = ShieldJS.siderE.find(\".shield-menus\").hide().eq(menuIndex); liMenuContainerE.show(); if (hasAttr(topMenuClickEle, \"action\")) { //使用action来异步加载 var actionUrl = topMenuClickEle.attr(\"action\"); ShieldJS.ajax.get(liMenuContainerE, actionUrl, {}, function(){ liMenuContainerE.removeClass(\"shieldMarked_shield-menus\"); ShieldJS.core.bindHtmlAction(liMenuContainerE); //初始化左侧栏内容 ShieldJS.core.initLeftMenu(ShieldJS.siderE, topBarE, topMenuClickEle, true); //选中默认左侧菜单节点 if (doClick == 'true') { //执行点击操作 var siderLiMenusE = liMenuContainerE.find('.shield-menu'); setDefaultSelectNode(liMenuContainerE, siderLiMenusE, topMenuClickEle, ShieldJS.siderE, true); } }); } else { //选中默认左侧菜单节点 if (doClick == 'true') { //执行点击操作 var siderLiMenusE = liMenuContainerE.find('.shield-menu'); setDefaultSelectNode(liMenuContainerE, siderLiMenusE, topMenuClickEle, ShieldJS.siderE, true); } } } // 执行父类点击操作 var doParClickEle = null; if (hasAttr(topMenuClickEle,\"doParClickEle\")) { doParClickEle = topMenuClickEle.attr(\"doParClickEle\"); } if (doParClickEle) { var parEle ; if (doParClickEle == \"..\") { //直接上级元素 parEle = topMenuClickEle.parent(); } else { parEle = topMenuClickEle.closest(doParClickEle); } parEle.click(); } // return false; //阻止冒泡 }); ShieldJS.core.initLeftMenu(ShieldJS.siderE, topBarE, null, false); //初始化菜单用于非ajax获取的左侧菜单，不设定默认选中的条目 //选中 setTimeout(function() { //延时，给其他事件的绑定时间 var selectIndex = 0; if (hasAttr(topMenuE, \"selectNode\")) { //默认选中节点，从0开始 selectIndex = Number.parseInt(topMenuE.attr(\"selectNode\")); } if (selectIndex != -1) { //-1表示不选中 var topMenu = topMenuE.find(\".menu\") if (topMenu.length &gt;0) { var clickEle = topMenu.eq(selectIndex); var doclick = topMenuE.data(\"doclick\") || \"true\"; console.log('doclick=='+doclick+\" \"+topMenuE.data(\"doclick\")); if (doclick == \"true\") { clickEle.click(); } } } }, 10); } /** * 左侧栏初始化，内置了3中菜单处理，1、普通菜单（选择器.shield-menus，方法ShieldJS.core.initLeftCommonMenu） * 2、树形菜单（选择器.shieldZTreeMenu,方法ShieldJS.core.initLeftZtreeMenu） 3、懒加载菜单（选择器.shieldLazyMenu,方法ShieldJS.core.initLeftExtendMenu） * 以上三个方法的默认实现如果不满足实际使用可以覆盖对应的方法，如果不在这三种里可以扩展（ShieldJS.core.initLeftExtendMenu） * @param siderE {jQueryObject} 左侧菜单栏对象 * @param topBarE {jQueryObject} 头部bar * @param topMenuClickEle {jQueryObject} 当前选中的头部菜单 * @param setDefaultSelect {Boolean} 是否设定默认选中项 */ ShieldJS.core.initLeftMenu = function(siderE, topBarE, topMenuClickEle, setDefaultSelect){ //左侧栏菜单 var liMenuContainerE = findAndMarkEle(siderE, \".shield-menus\"); //普通菜单容器，一般为ul&gt;li var ztreeMenuContainerE = findAndMarkEle(siderE, \".shieldZTreeMenu\"); //树形菜单容器 var shieldLazyMenuContainerE = findAndMarkEle(siderE, \".shieldLazyMenu\"); //延迟加载的菜单 //标准菜单ul、li if (liMenuContainerE.length&gt;0) { ShieldJS.core.initLeftCommonMenu(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect); //树形菜单li } else if (ztreeMenuContainerE.length &gt; 0 ) { ShieldJS.core.initLeftZtreeMenu(ztreeMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect); // 懒加载菜单 } else if (shieldLazyMenuContainerE.length &gt; 0 ) { ShieldJS.core.initLeftLazyMenu(shieldLazyMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect); } else { ShieldJS.core.initLeftExtendMenu(shieldLazyMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect); } }; /** * 左侧栏初始化::普通菜单的处理，一般为ul&gt;li * @param liMenuContainerE {jQueryObject} 左侧菜单栏普通菜单对象容器 * @param siderE {jQueryObject} 左侧菜单栏容器对象 * @param topBarE {jQueryObject} 头部bar * @param topMenuClickEle {jQueryObject} 当前选中的头部菜单 * @param setDefaultSelect {Boolean} 是否设定默认选中项 */ ShieldJS.core.initLeftCommonMenu = function(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect){ siderE.closest(\".shield-side\").removeClass(\"admin113-side-big\"); ShieldJS.contentMainE.css(\"left\",siderE.closest(\".shield-side\").width()); var siderLiMenusE = findAndMarkEle(liMenuContainerE, '.shield-menu'); if (siderLiMenusE.length &gt; 0) { siderLiMenusE.each(function(event) { var siderMenuClickEle = $(this); //左侧菜单栏选中 siderMenuClickEle.click(function() { ShieldJS.activeSiderE = siderMenuClickEle; if (hasAttr(siderMenuClickEle, \"clickExtendFn\")) { //自身的扩展点击事件，返回false则不执行原方法，返回true则继续原方法 var clickExtendFnName = siderMenuClickEle.attr(\"clickExtendFn\"); try { clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 } catch (e) { ShieldJS.error(\"菜单自定义点击事件方法\"+clickExtendFnName+\"出错，请检查方法定义！\"); } if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(event, liMenuContainerE, siderMenuClickEle, ShieldJS.contentMainE)){ return false; } } } else if (hasAttr(liMenuContainerE, \"clickExtendFn\")) { //父类的扩展点击事件，建议直接绑定到父类，方便管理 var clickExtendFnName = liMenuContainerE.attr(\"clickExtendFn\"); try { clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 } catch (e) { ShieldJS.error(\"菜单自定义点击事件方法\"+clickExtendFnName+\"出错，请检查方法定义！\"); } if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(event, liMenuContainerE, siderMenuClickEle, ShieldJS.contentMainE)){ return false; } } } ShieldJS.core.leftCommonMenuClickDoing(event, liMenuContainerE, siderMenuClickEle, ShieldJS.contentMainE); // siderLiMenusE.removeClass(ShieldJS.core.options.liMenuCurClass); // siderMenuClickEle.addClass(ShieldJS.core.options.liMenuCurClass); //重置选中样式 }); }); //菜单默默认点击事件，区分通过导向菜单过来的 setDefaultSelectNode(liMenuContainerE, siderLiMenusE, topMenuClickEle, siderE, setDefaultSelect); } }; /** * @description 设定默认选中的节点（执行点击） * @field （均为jquery对象） * options：配置参数 */ var setDefaultSelectNode = function(containerE, selectEles, topMenuClickEle, siderE, setDefaultSelect){ // 头部信息不为空，点击了导向菜单shieldForward if (selectEles &amp;&amp; selectEles.length &gt;0) { if (setDefaultSelect) { var shieldForwardEles = $(\"body\").find(\".shieldForward\"); if (shieldForwardEles.length &gt; 0) { shieldForwardEles.each(function(){ var shieldForwardEle = $(this); if (hasAttr(shieldForwardEle, \"toShieldMenu\") &amp;&amp; shieldForwardEle.data(\"forwarclickdo\")) {//有属性才处理 var toShieldMenuArr = shieldForwardEle.attr(\"toShieldMenu\").split(\"&gt;\"); if (toShieldMenuArr.length &gt; 1) { var toNavMenuE = $(toShieldMenuArr[0]); if (topMenuClickEle.is(toNavMenuE)) { //头部菜单是同一个对象 siderE.find(toShieldMenuArr[1]).click(); //左侧菜单点击 //siderE.scrollTop(0); var t_a = siderE.find(toShieldMenuArr[1]).offset(); //siderE.offset().top距顶部的高度 siderE.height()【siderE[0].offsetHeight】为可视高度 siderE[0].scrollHeight为实际高度 //scrollTop卷起的高度，头部0底部实际高度 // a.offset().top+siderE.scrollTop()=siderE.height()/2+siderE.offset().top+需要滚动的距离 siderE.animate({scrollTop:(t_a.top+siderE.scrollTop()-siderE.height()/2-siderE.offset().top)+ \"px\"}, 1000); //滚动到窗口中间 if (toShieldMenuArr.length == 2) { //2级导航到此结束，如果超过2级导航则后面继续处理，如多页签的情况等 shieldForwardEle.removeData(\"forwarclickdo\"); //跳转完成移除标记 } setDefaultSelect = false; // } } } }); } } if (setDefaultSelect) { //菜单默默认点击事件，区分通过导向菜单过来的 setTimeout(function() { //延时，给其他事件的绑定时间 var selectIndex = 0; if (hasAttr(containerE, \"selectNode\")) { //默认选中节点，从0开始 selectIndex = parseInt(containerE.attr(\"selectNode\")); } if (selectIndex != -1 &amp;&amp; selectEles.eq(selectIndex).length &gt; 0) { selectEles.eq(selectIndex).click(); } }, 100); } } } /** * 左侧普通菜单栏点击事件::普通菜单的处理，一般为ul&gt;li * @param event {Event} 事件对象 * @param liMenuContainerE {jQueryObject} 左侧菜单栏普通菜单对象容器 * @param siderMenuClickEle {jQueryObject} 左侧菜单点击的菜单对象 * @param contentMainE {jQueryObject} 内容区 */ ShieldJS.core.leftCommonMenuClickDoing = function(ele, liMenuContainerE, siderMenuClickEle, contentMainE){ } /** * 左侧栏初始化::树形菜单的处理，默认采用ztree * @param liMenuContainerE {jQueryObject} 左侧菜单栏普通菜单对象容器 * @param siderE {jQueryObject} 左侧菜单栏容器对象 * @param topBarE {jQueryObject} 头部bar * @param topMenuClickEle {jQueryObject} 当前选中的头部菜单 * @param setDefaultSelect {Boolean} 是否设定默认选中项 */ ShieldJS.core.initLeftZtreeMenu = function(ztreeMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect){ ShieldJS.debug(\"tree\"); siderE.closest(\".shield-side\").addClass(\"admin113-side-big\"); ShieldJS.contentMainE.css(\"left\",siderE.closest(\".shield-side\").width()); var getFont = function(treeId, node) { return node.font ? node.font : {}; } var jsTreeSetting = { data : { simpleData : { enable : true } }, view : { showIcon : false, fontCss: getFont, nameIsHTML: true }, callback : { onClick : function(e, treeId, treeNode) { if(treeNode){ var containerE = $(\"#\"+treeId); if (hasAttr(containerE,\"clickExtendFn\")) { //扩展点击事件 var clickExtendFnName = containerE.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if($.isFunction(clickExtendFnName)){ if(!clickExtendFnName(e, treeId, treeNode, contentE)){ return false; } } } var url = treeNode.urlNode; if (url) { //内容中自带链接 var params = {}; ShieldJS.ajax.get(contentE, url, params, function() { //内容区处理 if(!ShieldJS.core.contentAreaDeal(contentE, null, topMenuClickEle)){ return false; } }); } else if (containerE.data(\"urlNode\")) { //ul中公共链接 var url = containerE.data(\"urlNode\"); var paramAdapter = containerE.attr(\"paramAdapter\"); var params = {}; if (paramAdapter) { //paramAdapter=\"typeId=id#newsType\" var paramAdapters = paramAdapter.split(\"#\"); //#号分隔 for(var i=0;i&lt;paramAdapters.length;i++){ var paramName = paramAdapters[i]; if (paramName.indexOf(\"=\")!=-1) { var paramNames = paramName.split(\"=\"); //如果key与提交不一致用=号分隔 var paramsKey = paramNames[0]; var treeNodeKey = paramNames[1]; params[paramsKey] = treeNode[treeNodeKey]; } else { params[paramName] = treeNode[paramName]; } } ShieldJS.ajax.get(colContentEle, url, params, function() { //内容区处理 ShieldJS.contentMainE.css(\"left\", siderE.closest(\".shield-side\").width()+colContentEle.width()); if(!ShieldJS.core.contentAreaDeal(colContentEle, null, topMenuClickEle)){ return false; } }); } else { ShieldJS.error(\"未定义参数选择属性：请在\"+treeId+\"容器上添加paramAdapter属性并添加参数名，多个参数用#号连接\"); return false; } } } } } }; var searchEles = findAndMarkEle(siderE, '.shieldZTreeSearch'); //搜按钮 var loadZtree = function() { ztreeMenuContainerE.each(function(i, n){ var treeE = $(this); if(!$.fn.zTree){ ShieldJS.error(\"缺少依赖JS库：ZTree！\"+treeE.html()); return false; } if(typeof initZTree != \"undefined\" &amp;&amp; $.isFunction(eval(\"initZTree\"))){ initZTree(treeE, jsTreeSetting); //初始化，可做参数或其他预处理 } if(treeE.data(\"url\")){ //有链接才处理 if(hasAttr(treeE, \"asyncsetting\")){ //异步请求 jsTreeSetting.async = eval(treeE.attr(\"asyncsetting\")); } var url = treeE.data(\"url\"); var params = {}; if (hasAttr(treeE,\"paramSelector\")) { //参数选择器 params = ShieldJS.HtmlAction.checkAnGetParamSelector(treeE, params, siderE); //参数选择器 siderE.find(paramSelector).serializeJson(); if ($.isEmptyObject(params)) { ShieldJS.alert(\"消息提示\", \"参数为空！\", \"error\"); return false; } } params.timestamp = new Date().getTime(); //时间戳防缓存 params = getParams(treeE, params); $.getJSON(url, params, function(json) { if (json &amp;&amp; json.length &gt; 0) { $.fn.zTree.init(treeE, jsTreeSetting, json); var treeEId = treeE.attr(\"id\"); var treeObj = $.fn.zTree.getZTreeObj(treeEId); if(hasAttr(treeE,\"selectNode\")){ //默认选中节点 var selectNode = treeE.attr(\"selectNode\"); var defaultName = \"rownum\"; //默认属性 var selectNodeValue= selectNode; if (selectNode.indexOf(\"=\") != -1) { defaultName = selectNode.split(\"=\")[0]; selectNodeValue = selectNode.split(\"=\")[1]; } var node = treeObj.getNodeByParam(defaultName, selectNodeValue); treeObj.selectNode(node); treeObj.setting.callback.onClick(null, treeObj.setting.treeId, node); } } else { treeE.html('没有数据！'); } }); if (searchEles.length &gt; 0) { var searchE = searchEles.eq(i); searchE.click(function(event){ var params = {}; if (hasAttr(treeE,\"paramSelector\")) { //参数选择器 params = ShieldJS.HtmlAction.checkAnGetParamSelector(treeE, params, siderE); //参数选择器siderE.find(paramSelector).serializeJson(); if ($.isEmptyObject(params)) { ShieldJS.alert(\"消息提示\", \"参数为空！\", \"error\"); return false; } } params.timestamp = new Date().getTime(); //时间戳防缓存 params = getParams(treeE, params); if (hasAttr(searchE,\"clickExtendFn\")) { //扩展点击事件 var clickExtendFnName = searchE.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if($.isFunction(clickExtendFnName)){ if(!clickExtendFnName(event, params, treeE, jsTreeSetting)){ return false; } } } //未扩展，仍执行原查询 $.getJSON(url, params, function(json) { if (json &amp;&amp; json.length &gt; 0) { $.fn.zTree.init(treeE, jsTreeSetting, json); } else { treeE.html('没有数据！'); } }); }); } } }); }; loadZtree(); }; /** * 左侧栏初始化::懒加载菜单的处理 * @param liMenuContainerE {jQueryObject} 左侧菜单栏普通菜单对象 * @param siderE {jQueryObject} 左侧菜单栏容器对象 * @param topBarE {jQueryObject} 头部bar * @param topMenuClickEle {jQueryObject} 当前选中的头部菜单 * @param setDefaultSelect {Boolean} 是否设定默认选中项 */ ShieldJS.core.initLeftLazyMenu = function(shieldLazyMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect){ siderE.closest(\".shield-side\").addClass(\"admin113-side-big\"); ShieldJS.contentMainE.css(\"left\",siderE.closest(\".shield-side\").width()); var targetEPar = null; if (hasAttr(shieldLazyMenuContainerE,\"target\")) { //ul中公共链接 targetEPar = getjQueryObj(shieldLazyMenuContainerE.attr(\"target\")); } var siderLiMenusE = findAndMarkEle(shieldLazyMenuContainerE, '.shield-menu'); siderLiMenusE.each(function(event) { var siderMenuClickEle = $(this); //左侧菜单栏选中 if (hasAttr(siderMenuClickEle,\"clickExtendFn\")) { //扩展点击事件 var clickExtendFnName = liMenuContainerE.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(event, liMenuContainerE, siderMenuClickEle, contentE)){ return false; } } } if (siderMenuClickEle.data(\"url\")) {//有链接才处理 siderMenuClickEle.click(function() { ShieldJS.activeSiderE = siderMenuClickEle; var params = {}; if (hasAttr(siderMenuClickEle,\"paramSelector\")) { //参数选择器 params = ShieldJS.HtmlAction.checkAnGetParamSelector(siderMenuClickEle, params, siderMenuClickEle); //参数选择器 if ($.isEmptyObject(params)) { ShieldJS.alert(\"消息提示\",\"参数为空！\", \"error\"); return false; } } var hrefmenu = siderMenuClickEle.data(\"url\"); ShieldJS.ajax.get(targetEPar, hrefmenu, params, function() { //内容区处理 contentMainE.css(\"left\", siderE.closest(\".shield-side\").width() + colContentEle.width()); if(!ShieldJS.core.contentAreaDeal(targetEPar, siderMenuClickEle, topMenuClickEle)){ return false; } }); return false; //阻止冒泡 }); //siderE.find(\"li\").removeClass(ShieldJS.core.options.liMenuCurClass); //siderMenuClickEle.addClass(ShieldJS.core.options.liMenuCurClass); //选中 } }); }; /** * 左侧栏初始化::扩展菜单（空方法，用于框架扩展） * @param liMenuContainerE {jQueryObject} 左侧菜单栏普通菜单对象 * @param siderE {jQueryObject} 左侧菜单栏容器对象 * @param topBarE {jQueryObject} 头部bar * @param topMenuClickEle {jQueryObject} 当前选中的头部菜单 * @param setDefaultSelect {Boolean} 是否设定默认选中项 */ ShieldJS.core.initLeftExtendMenu = function(shieldLazyMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect){ } //----------------------------------------------------------------------------- //-------------------------------以下为私有方法--------------------------------- //----------------------------------------------------------------------------- /** * 私有变量，框架的默认配置，外部不可见 * @namespace ShieldJS.core._defaults * @property {String/jQueryObj} topBarE - 头部信息区（jQuery对象或选择器） * @property {String/jQueryObj} topMenuE - 头部菜单区（jQuery对象或选择器） * @property {String/jQueryObj} siderE - 左侧栏（jQuery对象或选择器） * @property {String/jQueryObj} contentMainE - 主内容区（jQuery对象或选择器） * @property {String/jQueryObj} contentNavTabE - 主内容区navTab（jQuery对象或选择器） * @property {String/jQueryObj} contentActiveTabE - 主内容区当前活动Tab（jQuery对象或选择器） * @property {String} navMenuCurClass - 内容区多页签选项卡选中的样式 * @property {String} headerCurClass - 内容区多页签选项卡选中的样式 * @property {String} liMenuCurClass - 左侧菜单选中的样式 * @property {String} bindHtmlErrorCallback - html绑定失败回调方法(actionName, e) * @property {String} bindHtmlSuccCallback - html绑定成功回调方法 * @property {String} bindHtmlCallback - html绑定完成回调方法（成功失败都会调用） * @property {String} templPath - 模板路径，不填找templ目录下的文件，自定义目录时文件名需要保持一致 */ var _defaults = { /** 头部信息 */ topBarE : '#userBar' /** 头部菜单区 */ ,topMenuE : '#navMenu' //头部菜单区 /** 左侧栏 */ ,siderE : '#leftBar' /** 主内容区（容器） */ ,contentMainE : '#content' /** 主内容区navTab */ ,contentNavTabE : '#contentNavTab' /** 主内容区当前活动Tab */ ,contentActiveTabE : '.tab-pane.active' /** 菜单栏中菜单选中的样式*/ ,navMenuCurClass : 'cur' /** 内容区多页签选项卡选中的样式 */ ,headerCurClass : 'cur' /** 左侧菜单选中的样式*/ ,liMenuCurClass : 'active' /** html绑定失败回调方法(actionName, e) */ ,bindHtmlErrorCallback : null /** html绑定成功回调方法 */ ,bindHtmlSuccCallback : null /** html绑定完成回调方法（成功失败都会调用）*/ ,bindHtmlCallback : null /** 模板路径，扩展字段默认不需要，用于一些需要模板的实现，不填找templ目录下的文件，自定义目录时文件名需要保持一致 */ ,templPath : 'templ' }; /** * @description 获取框架结构的页面元素 * @field （均为jquery对象） * options：配置参数 */ var getPageFrameEle = function(options) { ShieldJS.topBarE = options.topBarE ? getjQueryObj(options.topBarE) : null; //头部信息区 ShieldJS.topMenuE = options.topMenuE ? getjQueryObj(options.topMenuE) : null; //头部菜单区 ShieldJS.siderE = options.siderE ? getjQueryObj(options.siderE) : null; //主内容区 //左侧栏 ShieldJS.contentMainE = options.contentMainE ? getjQueryObj(options.contentMainE) : null; //主内容区 if(ShieldJS.topBarE &amp;&amp; ShieldJS.topBarE.length == 0){ ShieldJS.error(\"topBarE定义元素未找到，请检查是否配置正确！\"); } if(ShieldJS.topMenuE &amp;&amp; ShieldJS.topMenuE.length == 0){ ShieldJS.error(\"topMenuE定义元素未找到，请检查是否配置正确！\"); } if(ShieldJS.siderE &amp;&amp; ShieldJS.siderE.length == 0){ ShieldJS.error(\"siderE定义元素未找到，请检查是否配置正确！\"); } if(ShieldJS.contentMainE &amp;&amp; ShieldJS.contentMainE.length == 0){ ShieldJS.error(\"contentMainE定义元素未找到，请检查是否配置正确！\"); } } /** * @description 处理页面处理（带提交事件） * @field （均为jquery对象） * contentE：内容dom menuliSelectE：左侧栏选中的menu topMenuSelectE：导航栏选中的menu */ var contentWithSubmitDeal = function(contentE, menuliSelectE, topMenuSelectE){ var searchForm = findAndMarkEle(contentE, 'form.searchForm'); var submitForm = findAndMarkEle(contentE, 'form.submitForm'); var shieldExtendCallback = findAndMarkEle(contentE, '.shieldExtendCallback'); //自定义处理事件的元素 if (searchForm.length &gt; 0) { // 有搜索表单时的处理(class=\"searchForm\") ShieldJS.core.bindHtmlAction(contentE, menuliSelectE, topMenuSelectE, searchForm); // 提交表单完成后执行方法 ShieldJS.form.initSubmit(contentE, function(formE, targetE, data){ // 初始化页面内容 ShieldJS.core.bindHtmlAction(contentE, menuliSelectE, topMenuSelectE, searchForm); }); var notAutoSubmit = false; if(hasAttr(searchForm, \"notAutoSubmit\")){ //页面初始化后不自动提交 notAutoSubmit = searchForm.attr(\"notAutoSubmit\"); notAutoSubmit = notAutoSubmit=='false' ? false : true; } if (!notAutoSubmit) { //自动提交 searchForm.submit(); } else { ShieldJS.core.bindHtmlAction(contentE, menuliSelectE, topMenuSelectE, searchForm); } } else if (shieldExtendCallback.length &gt; 0) { // 自定义回调处理 ShieldJS.core.bindHtmlAction(contentE, menuliSelectE, topMenuSelectE); var successDo = ShieldJS.HtmlAction.successDo.shieldRefresh; if (hasAttr(shieldExtendCallback, \"successDo\")) { //保存成功后的处理 successDo = shieldExtendCallback.attr(\"successDo\"); } //提交表单完成后执行方法 ShieldJS.form.initSubmit(contentE, function(formE, targetE, data){ ShieldJS.HtmlAction.formSubmitCallback(successDo, formE, targetE, data, menuliSelectE, topMenuSelectE); }); var callbackFn = shieldExtendCallback.attr(\"callback\"); callbackFn = eval(callbackFn); //字符串转换为方法 if ($.isFunction(callbackFn)) { callbackFn(shieldExtendCallback, successDo); //需要自定义 } } else {// 没有form的处理，可能为单页修改的页面 ShieldJS.core.bindHtmlAction(contentE, menuliSelectE, topMenuSelectE); // 如果存在shieldDonothing 的类，则什么都不做，默认刷新 if(contentE.find(\".\"+ShieldJS.HtmlAction.successDo.shieldDonothing).length == 0){ //提交表单完成后执行方法 ShieldJS.form.initSubmit(contentE,function(formE, targetE, data){ if(menuliSelectE){ menuliSelectE.click(); } }); } } } /** * @description 多页签的a点击事件 * @field * （以下均为jquery对象） * comPeriodContentE：内容dom shieldHeader：头部dom * siderMenuClickEle：左侧栏点击菜单 topMenuClickEle：当前选中的头部菜单 */ var shieldAClickFn = function(comPeriodContentE, shieldHeader, siderMenuClickEle, topMenuClickEle){ var shieldHeaderAEles = findAndMarkEle(shieldHeader, 'a'); shieldHeaderAEles.click(function() { var curHeaderA = $(this); shieldHeader.find('a').removeClass(ShieldJS.core.options.headerCurClass); curHeaderA.addClass(ShieldJS.core.options.headerCurClass); if (hasAttr(siderMenuClickEle,\"shieldHeaderUrl\")) { //父元素有链接（用于公共页面不能直接添加url的处理） var shieldHeaderUrl = siderMenuClickEle.attr(\"shieldHeaderUrl\"); var curHeaderAHref = shieldHeaderUrl; var params = {type : curHeaderA.attr('v')}; //用v区分类型（必需） params = getParams(curHeaderA,params); shieldTabDeal(curHeaderAHref, params, comPeriodContentE, shieldHeader, curHeaderA, siderMenuClickEle, topMenuClickEle); } else { //普通带href处理 var juniorResult = checkJuniorE(comPeriodContentE,curHeaderA); if(!juniorResult.hasErr){ var juniorE = juniorResult.juniorE; if (juniorE) { shieldAClickFn(comPeriodContentE, juniorE, siderMenuClickEle, topMenuClickEle); } else { if(curHeaderA.data(\"url\")){ //有链接才处理 var curHeaderAHref = curHeaderA.data(\"url\"); var params = {type : curHeaderA.attr('v')}; //用v区分类型（非必需） params = getParams(curHeaderA, params); shieldTabDeal(curHeaderAHref, params, comPeriodContentE, shieldHeader, curHeaderA, siderMenuClickEle, topMenuClickEle); } } } } return false; }); shieldHeader.find('a:eq(0):not(.noshield)').click(); } /** * @description 检查并处理下级容器，返回子级容器 * @field * （以下均为jquery对象） * contentE：内容dom curHeaderClickE：当前选中的头部dom */ var checkJuniorE = function(contentE,curHeaderClickE){ var result = { hasErr : false, juniorE :null } ShieldJS.contentMainE.find(\".shieldJunior\").each(function(){ var shieldJuniorE = $(this); if (hasAttr(shieldJuniorE,\"juniorFor\")) { var juniorFor = shieldJuniorE.attr(\"juniorFor\"); if (shieldJuniorE.find(curHeaderClickE).length == 0) { //非父类元素 if (curHeaderClickE.is($(juniorFor))) { shieldJuniorE.show(); result.juniorE = shieldJuniorE; return shieldJuniorE; //不能直接跳出 } else { shieldJuniorE.hide(); } } } else { ShieldJS.error(\"shieldJunior下级容器未定义关联到的上级容器：请定义属性juniorFor\"); result.hasErr = true; return false; } }); return result; } /** * @description 处理tab格式的页面 * @field * href：链接 params：参数 * （以下均为jquery对象） * comPeriodContentE：内容dom shieldHeader：头部dom * curHeaderA：当前选中的头部dom menuliSelectE：左侧栏选中的menu topMenuSelectE：导航栏选中的menu */ var shieldTabDeal = function(url, params, comPeriodContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE){ var thisContentE = comPeriodContentE; var errCallbackFn = null; var completeCallbackFn = null; if (curHeaderA) { if (hasAttr(curHeaderA,\"errCallbackFn\")) { //返回失败方法 var clickExtendFnName = curHeaderA.attr(\"errCallbackFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { errCallbackFn = function(data){ // 如果是错误，则为json格式，自动格式化 var json; try { json = $.parseJSON(data); } catch (e) { json = ''; } if(!json){ // 转换错误时，赋值为原来的值 json = data; } clickExtendFnName(json, thisContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE); }; // if(!clickExtendFnName(data, thisContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE)){ // return false; // } } } if (hasAttr(curHeaderA,\"completeCallbackFn\")) { //完成后回调方法 var clickExtendFnName = curHeaderA.attr(\"completeCallbackFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { completeCallbackFn = function(data){ clickExtendFnName(data, thisContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE); }; // if(!clickExtendFnName(data, thisContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE)){ // return false; // } } } if (hasAttr(curHeaderA,\"clickExtendFn\")) { //扩展点击事件 var clickExtendFnName = curHeaderA.attr(\"clickExtendFn\"); clickExtendFnName = eval(clickExtendFnName); //字符串转换为方法 if ($.isFunction(clickExtendFnName)) { if(!clickExtendFnName(thisContentE, shieldHeader, curHeaderA, menuliSelectE, topMenuSelectE)){ return false; } } } } ShieldJS.ajax.get(comPeriodContentE, url, params, function(data) { if (!menuliSelectE || menuliSelectE.length == 0 ) { //针对多页签 menuliSelectE = curHeaderA; } contentWithSubmitDeal(comPeriodContentE, menuliSelectE, topMenuSelectE); }, errCallbackFn, completeCallbackFn); } //----------------------------------------------------------------------------- //-------------------------------jQuery插件化---------------------------------- //----------------------------------------------------------------------------- /** * 页面HTML元素处理（绑定HTML处理，只在页面上邦迪html处理，如果包含tab则使用上面的方法） * @author kevin Lv &lt;donggongai@126.com&gt; * @class $().shieldBindHtmlAction * @param {json} options - 配置参数,topBarE为topBar元素或者对应的选择器,topMenu头部导航栏对应的menu元素或者对应的选择器,searchForm为搜索表单元素或者对应的选择器，dialog为弹出框对象(类型为ShieldJS.dialog) * * @example * $(\"#content\").shieldBindHtmlAction(); * //带参数的用法 topBarE为topBar元素或者对应的选择器,topMenu头部导航栏对应的menu元素或者对应的选择器,searchForm为搜索表单元素或者对应的选择器，dialog为弹出框对象(类型为ShieldJS.dialog) * $(\"#content\").shieldBindHtmlAction({leftMenu:'#leftMenu',topMenu:'#topMenu',searchForm:'.sarchForm',dialog:dialog}); * * @since version 1.0 */ $.fn.shieldBindHtmlAction = function(options){ if(!options){ options = {}; } //动态绑定，页面初始化之后加入的也可以绑定 $(\"body\").off(\"click\", \".shieldForward\").on(\"click\", \".shieldForward\", function(event){ var shieldForwardEle = $(this); if (!shieldForwardEle.data(\"forwardclickinit\")) { //防止重复处理 if (hasAttr(shieldForwardEle,\"toShieldMenu\")) { //有菜单属性才处理 var toShieldMenuArr = shieldForwardEle.attr(\"toShieldMenu\").split(\"&gt;\"); if (toShieldMenuArr.length &gt; 1) { var toNavMenu = $(toShieldMenuArr[0]); //头部菜单 shieldForwardEle.data(\"forwarclickdo\",toShieldMenuArr[1]); //添加属性，跳转完成后移除 toNavMenu.click(); } } } }); /** * @description 处理函数 */ return this.each(function() { var $this = $(this); //使用metadata插件获取元数据 var ops = $.metadata ? $.extend({}, options, $this.metadata()) : options; var leftMenuClickEle = getjQueryObj(ops.leftMenu); var topMenuClickEle = getjQueryObj(ops.topMenu); var searchFormE = getjQueryObj(ops.sarchForm); var shieldDialog = getjQueryObj(ops.dialog); ShieldJS.core.bindHtmlAction($this, leftMenuClickEle, topMenuClickEle, searchFormE, shieldDialog); }); }; /** * 左侧菜单处理，并处理内容区 * @author kevin Lv &lt;donggongai@126.com&gt; * @class $().shieldLeftMenu * @param {json} options - 配置参数,参考{@link ShieldJS.core._defaults}, topMenuClickEle头部导航栏对应的菜单选项 * * @example * $(\"#content\").shieldLeftMenu(); * //带参数的用法 topMenuClickEle头部导航栏对应的菜单选项 * $(\"#content\").shieldLeftMenu({topBarE:'#topBar',topMenuE:'#navMenu'}); * * @since version 1.0 */ $.fn.shieldLeftMenu = function(options){ /** * @description 处理函数 */ return this.each(function() { var $this = $(this); //使用metadata插件获取元数据 var ops = $.metadata ? $.extend({}, options, $this.metadata()) : options; ShieldJS.core.options = $.extend({},_defaults, ops); getPageFrameEle(ShieldJS.core.options); //页面框架元素获取 var topMenuClickEle = getjQueryObj(ops.topMenuClickEle); ShieldJS.core.initLeftMenu($this, ShieldJS.topBarE, topMenuClickEle); $(\"body\").shieldBindHtmlAction(); //初始化页面内容 }); }; /** * 初始化页面HTML元素处理（与$.fn.shieldBindHtmlAction方法代码类似，区别在于本方法处理多页签，包含form回调方法） * @author kevin Lv &lt;donggongai@126.com&gt; * @class $().shieldMainContent * @param {json} options - 配置参数 * * @example * $(\"#content\").shieldMainContent(); * //带参数的用法 leftMenuClickE为左侧栏选中的菜单，topMenuClickEle为头部菜单选中的菜单 * $(\"#content\").shieldMainContent({leftMenuClickE:'#leftMenu',topMenuClickEle:'#topMenu'}); * * @since version 1.0 */ $.fn.shieldMainContent = function(options){ if(!options){ options = {}; } /** * @description 处理函数 */ return this.each(function() { var $this = $(this); //使用metadata插件获取元数据 var ops = $.metadata ? $.extend({}, options, $this.metadata()) : options; var leftMenuClickEle = getjQueryObj(ops.leftMenuClickE); var topMenuClickEle = getjQueryObj(ops.topMenuClickEle); ShieldJS.core.contentAreaDeal($this, leftMenuClickEle, topMenuClickEle); }); }; })(jQuery); × Search results Close "},"shield.HtmlAction.js.html":{"id":"shield.HtmlAction.js.html","title":"Source: shield.HtmlAction.js","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Source: shield.HtmlAction.js //html标签的js动作处理 (function($){ ShieldJS.HtmlAction = { /** 处理成功后的回调方法名 * @class ShieldJS.HtmlAction.successDo */ successDo : { /** 刷新，关闭dialog，并刷新搜索表单(默认) * @type String */ shieldRefresh: \"shieldRefresh\", /** 什么都不做 * @type String */ shieldDonothing: \"shieldDonothing\", /** 只刷新搜索表单 * @type String */ shieldReSearch: \"shieldReSearch\", /** 只关闭dialog * @type String */ shieldDialogRemove: \"shieldDialogRemove\", /** 刷新Tab（有dialog也会关闭）,用于多页签内容页的刷新 * @type String */ shieldRefreshTab: \"shieldRefreshTab\", /** 刷新Tab（不关闭dialog）,用于多页签内容页的刷新 * @type String */ shieldRefreshTabIgnoreDialog: \"shieldRefreshTabIgnoreDialog\", /** 自定义方法 * @type String */ shieldExtend: \"shieldExtend\" // }, names : { shieldSelectRow : \"shieldSelectRow\", shieldSelectRowByshieldCheck : \"shieldSelectRowByshieldCheck\" }, /** 处理成功后的回调执行方法 * @class ShieldJS.HtmlAction.successDoMethod */ successDoMethod : { shieldRefresh : function(contentE, searchForm, menuliSelect, dialog, oldRefresh){ //刷新，关闭dialog，并刷新搜索表单(默认) if (dialog) { dialog.remove(); } if (searchForm) { if (!oldRefresh) { //兼容旧框架的json返回，不重复刷新 searchForm.submit(); } } else if (menuliSelect) { menuliSelect.click(); } }, shieldDonothing : function(contentE, searchForm, menuliSelect, dialog, oldRefresh) { //什么都不做 }, shieldReSearch : function(contentE, searchForm, menuliSelect, dialog, oldRefresh) { //只刷新搜索表单 if (searchForm) { if (!oldRefresh) { //兼容旧框架的json返回，不重复刷新 searchForm.submit(); } } else if (menuliSelect) { menuliSelect.click(); } }, shieldDialogRemove : function(contentE, searchForm, menuliSelect, dialog, oldRefresh) { //只关闭dialog if (dialog) { dialog.remove(); } }, shieldRefreshTabDealFn : function(contentE, searchForm, menuliSelect, dialog, closeDialog) { //刷新Tab处理函数，内部使用 var shieldHeader = contentE.find(\".shieldHeader\"); if (shieldHeader.length &gt; 0) { if (closeDialog &amp;&amp; dialog) { dialog.remove(); } var headerCurClasses = ShieldJS.core.options.headerCurClass.replace(\" \",\".\"); var shieldJuniorSelectE = contentE.find(\".shieldJunior.\"+headerCurClasses); if(shieldJuniorSelectE.length &gt; 0){ shieldJuniorSelectE.click(); } else { var shieldHeaderSelectE = shieldHeader.find(\".\"+headerCurClasses); if(shieldHeaderSelectE.length &gt; 0){ shieldHeaderSelectE.click(); } } } }, shieldRefreshTab : function(contentE, searchForm, menuliSelect, dialog, oldRefresh) { //刷新Tab,用于多页签内容页的刷新 ShieldJS.HtmlAction.successDoMethod.shieldRefreshTabDealFn(contentE, searchForm, menuliSelect, dialog, true) }, shieldRefreshTabIgnoreDialog : function(contentE, searchForm, menuliSelect, dialog, oldRefresh) { //刷新Tab（不关闭，dialog）,用于多页签内容页的刷新 ShieldJS.HtmlAction.successDoMethod.shieldRefreshTabDealFn(contentE, searchForm, menuliSelect, dialog, false) }, shieldExtend : function(contentE, searchForm, menuliSelect, dialog, oldRefresh, result) { //自定义 } }, /** 检查成功的回调函数是否存在 * @param successDoName {String} 成功后的回调方法名 * @returns {Boolean} 方法存在时返回true，否则返回false */ checkSuccessDoMethodExist : function (successDoName) { if(!$.isFunction(ShieldJS.HtmlAction.successDoMethod[successDoName])){ var suddceeDoExtendFn = eval(successDoName); //自定义的回调方法 if(!$.isFunction(suddceeDoExtendFn)){ ShieldJS.error(successDo + \"成功后的回调处理函数不存在！\"); return false; } } return true; }, /** 指定成功的回调函数,result为成功返回的结果 * @param successDoName {String} 成功后的回调方法名 */ execSuccessDoMethod : function (successDoName, contentE, searchForm, menuliSelect, dialog, oldRefresh, result) { if($.isFunction(ShieldJS.HtmlAction.successDoMethod[successDoName])){ //预定于的回调方法 ShieldJS.HtmlAction.successDoMethod[successDoName](contentE, searchForm, menuliSelect, dialog, oldRefresh, result); } else { var suddceeDoExtendFn = eval(successDoName); //自定义的回调方法 if($.isFunction(suddceeDoExtendFn)){ suddceeDoExtendFn(contentE, searchForm, menuliSelect, dialog, oldRefresh, result); } } }, //post提交数据 postData : function(url, params, contentE, searchForm, menuliSelect, shieldDialog, successDo, methodType, successCallback) { var method = \"post\"; if ($.isFunction(methodType)) { //是函数，则为successCallback successCallback = methodType; }else { method = methodType; } if (method == \"get\") { ShieldJS.ajax.get(null, url, params, function(json) { ShieldJS.HtmlAction.execSuccessDoMethod(successDo, contentE, searchForm, menuliSelect, shieldDialog, json.refresh, json); if (successCallback) { successCallback(); } }, function(json) { ShieldJS.debug(\"提交数据出错！\" + url + \" params: \" + $.param(params)); }); } else { ShieldJS.ajax.post(url, params, function(json) { ShieldJS.HtmlAction.execSuccessDoMethod(successDo, contentE, searchForm, menuliSelect, shieldDialog, json.refresh, json); if (successCallback) { successCallback(); } }, function(json) { ShieldJS.debug(\"提交数据出错！\" + url + \" params: \" + $.param(params)); }, \"json\"); } }, //检查并返回参数,如果正常返回params否则返回false checkAnGetParamSelector : function(ele, params, contentEle){ if (!contentEle) { contentEle = ShieldJS.contentMainE; //主内容区没有包含弹出框 if (ShieldJS.dialogE) { //增加弹出框对象 ，注意此处未做回归测试，可能有问题 contentEle = contentEle.add(ShieldJS.dialogE); } } if (hasAttr(ele, \"paramSelector\")) { //参数选择器 var bodyE = $(\"body\"); var paramSelector = ele.attr(\"paramSelector\"); /*{selectRows}表示复选框选中行的数据作为参数提交，如果只想选一部分可以在里面增加选择器 {selectRows&gt;:checkbox}意思为只提交选中行的的checkbox作为参数,用'&gt;'连接选择器，里面的选择器为jQuery选择器*/ if (paramSelector.indexOf(\"{selectRows\") != -1 ) { //选中行用&gt;分隔内部选择器 // 括号表示组。访问可以用group[index]来访问每组的信息 var linkRegx = /.*{(selectRows.*?)},?/; var group = paramSelector.match(linkRegx); if (group.length == 2) { //如果包含则为长度为2 var selectRows = group[1]; //selectRows var selectRowsEle = contentEle.find(\".\"+ShieldJS.HtmlAction.names.shieldSelectRowByshieldCheck); if(selectRows.indexOf(\"&gt;\") &gt; 0){ //过滤 var selectRowsArrs = selectRows.split(\"&gt;\"); selectRowsEle = contentEle.find(\".\"+ShieldJS.HtmlAction.names.shieldSelectRowByshieldCheck).filter(selectRowsArrs[1]); } if (!selectRowsEle.is(\":input\")) { //如果不是input，继续查找内部的input selectRowsEle = selectRowsEle.find(\":input\"); } if (ShieldJS.form.validate(selectRowsEle)) { params = $.extend(true, {}, params, selectRowsEle.serializeJson()); if ($.isEmptyObject(params)) { ShieldJS.alert(\"消息提示\", \"至少选中一条信息！\", \"error\"); return false; } } else { ShieldJS.debug(\"参数选择器验证未通过！\"); return false; } } else { ShieldJS.error(\"参数选择器参数设置错误，请检查{selectRows}！\"); return false; } paramSelector = paramSelector.replace(linkRegx, \"\"); } if (paramSelector.indexOf(\"{currRows\") != -1 ) {//当前行用&gt;分隔内部选择器 // 括号表示组。访问可以用group[index]来访问每组的信息 var linkRegx = /.*{(currRows.*?)},?/; var group = paramSelector.match(linkRegx); if (group.length == 2) { //如果包含则为长度为2 var selectRows = group[1]; //selectRows var selectRowsEle = ele.closest(\"tr\"); if(selectRows.indexOf(\"&gt;\") &gt; 0 ){ //过滤 var selectRowsArrs = selectRows.split(\"&gt;\"); selectRowsEle = cselectRowsEle.filter(selectRowsArrs[1]); } if (!selectRowsEle.is(\":input\")) { //如果不是input，继续查找内部的input selectRowsEle = selectRowsEle.find(\":input\"); } if (ShieldJS.form.validate(selectRowsEle)) { params = $.extend(true, {}, params, selectRowsEle.serializeJson()); } else { ShieldJS.debug(\"参数选择器验证未通过！\"); return false; } } else { ShieldJS.error(\"参数选择器参数设置错误，请检查{currRows}！\"); return false; } paramSelector = paramSelector.replace(linkRegx, \"\"); } if (paramSelector) { //继续检查 var selectEles = contentEle.find(paramSelector); if (ShieldJS.form.validate(selectEles)) { params = $.extend(true, {}, params, selectEles.serializeJson()); if ($.isEmptyObject(params)) { ShieldJS.alert(\"消息提示\", \"参数为空，请返回检查！\", \"error\"); return false; } } else { ShieldJS.debug(\"参数选择器验证未通过！\"); return false; } } } return params; }, // 检查自定义点击回调方法是否存在 hasClickCallbackFn : function(ele, eventName) { var $events = $._data(ele[0], \"events\"); if( $events &amp;&amp; $events[eventName] ){ return true; } return false; }, // 自定义点击回调 clickCallback : function(ele) { var eventName = \"clickCallback\"; if (ShieldJS.HtmlAction.hasClickCallbackFn(ele, eventName)) { var $events = $._data(ele[0],\"events\"); if( $events &amp;&amp; $events[eventName] ){ ele.trigger(eventName); } } }, /** 表单提交成功后的回调方法 * @param successDo {String} 成功后的回调方法名 * @param formE {jQuery} 表单对象 * @param targetE {jQuery} 表单提交的目标对象 * @param data {Object} 返回结果的对象可能为json也可能为页面字符 * @param menuliSelect {jQuery} 左侧栏menu * @param navMenuSelect{jQuery} 导航栏menu * @param searchForm {jQuery} 搜索表单 * @param dialog {ShieldJS.dialog} 弹出框对象 * */ formSubmitCallback : function(successDo, formE, targetE, data, menuliSelect, navMenuSelect, searchForm, dialog ) { var successDoForm = successDo; if (hasAttr(formE, \"successDo\")) { //form上保存成功后的处理 successDoForm = formE.attr(\"successDo\"); } if (successDoForm) { //回调 if (!ShieldJS.HtmlAction.checkSuccessDoMethodExist(successDoForm)) { return false; } else { // 为json格式 var json; if (typeof data == 'object') { json = data; } else { try { json = $.parseJSON(data); } catch (e) { json = ''; } } ShieldJS.HtmlAction.execSuccessDoMethod(successDoForm, ShieldJS.contentMainE, searchForm, menuliSelect, dialog, json.refresh, json); } } if (targetE &amp;&amp; targetE.is(\":visible\")) { //未关闭 ShieldJS.core.bindHtmlAction(targetE, menuliSelect, navMenuSelect, searchForm, dialog); //内部继续加载,已经默认实现 } }, /** html元素的扩展动作方法 * @class ShieldJS.HtmlAction.HTMLEleActions * */ HTMLEleActions : { /** 弹出窗口，添加，显示，修改等；查找带回 */ shieldDialogOrLookup: { expression : '.shieldDialog,.shieldLookup', /* selectE：选中的元素dom menuliSelect：左侧栏menu navMenuSelect：导航栏menu searchForm：搜索表单 shieldDialog：弹出框 */ fn : function(selectE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ //存在checkFn时contentE为checkFn函数的返回值 selectE.unbind(\"click\").click(function() { var $this = $(this); if(hasAttr($this,\"confirm\")){ //确认信息 var confirmMsg = $this.attr(\"confirm\"); if(!confirm(confirmMsg)){ return false; } } var relType; //iframe if($this.data(\"relType\")){ //打开类型,data-rel-type relType = $this.data(\"relType\"); } var viewTitle = \"信息\"; if(hasAttr($this,ShieldJS.css.TITLE)){ viewTitle = $this.attr(ShieldJS.css.TITLE); } var viewWidth = 500; if(hasAttr($this,ShieldJS.css.WIDTH)){ viewWidth = $this.attr(ShieldJS.css.WIDTH); } var viewHeight = 600; //iframe打开时用到 if(hasAttr($this,ShieldJS.css.HEIGHT)){ viewHeight = $this.attr(ShieldJS.css.HEIGHT); } var url = $this.data(\"url\"); var params = {}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this,params); var successDo = ShieldJS.HtmlAction.successDo.shieldRefresh; if (hasAttr($this, \"successDo\")) { //保存成功后的处理 successDo = $this.attr(\"successDo\"); } ShieldJS.openDialog(url, params, function(ele, dialog) { ShieldJS.form.initSubmit(ele, function(formE, targetE, data) {//成功后 ShieldJS.HtmlAction.formSubmitCallback(successDo, formE, targetE, data,menuliSelect, navMenuSelect, searchForm, dialog); }); //默认输入光标在第一个输入框内 var eleInput = findAndMarkEle(ele, 'input[type=\"text\"],textarea'); var inputLength = eleInput.length; if(inputLength&gt;0) { eleInput.eq(0).focus(); } //查找带回 if($this.hasClass(\"shieldLookup\")){ var selectBtnEles = findAndMarkEle(ele, \".selectBtn\"); //选择按钮 var formE = $this.closest(\"form\"); selectBtnEles.click(function(){ var selectBtnEle = $(this); var thisIndex = formE.find(\".shieldLookup\").index($this); formE.find(':input.shieldLookupId').eq(thisIndex).val(selectBtnEle.data(\"id\")).triggerHandler(\"change\");//触发自定义change事件 var shieldLookupShowNameEle = formE.find('.shieldLookupName').eq(thisIndex); var isInput = shieldLookupShowNameEle.is(\":input\"); if(isInput){ shieldLookupShowNameEle.val(selectBtnEle.data(\"name\")); }else{ shieldLookupShowNameEle.text(selectBtnEle.data(\"name\")); } shieldLookupShowNameEle.triggerHandler(\"change\");//触发自定义change事件 dialog.remove(); }); } //ShieldJS.core.bindHtmlAction(ele, menuliSelect, navMenuSelect, searchForm, dialog); //内部继续加载,已经默认实现 }, viewTitle, viewWidth, viewHeight, null, relType); return false; }); }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ var dealEle = findAndMarkEle(contentE, this.expression); if (dealEle.length &gt; 0) { dealEle.each(function(){ var eleName = \"shieldDialog元素\"; var $this = $(this); //查找带回 if ($this.hasClass(\"shieldLookup\")) { eleName = \"shieldDialog元素\"; var formE = $this.closest(\"form\"); if (formE.length == 0) { ShieldJS.error(eleName + \"元素需要包含在form内部！\"); return false; } var shieldLookupEles = formE.find(\".shieldLookup\"); var shieldLookupShowIdEles = formE.find(':input.shieldLookupId');//触发自定义change事件 var shieldLookupShowNameEles = formE.find('.shieldLookupName'); if (shieldLookupEles.length != shieldLookupShowIdEles.length) { ShieldJS.error(eleName + \"个数与shieldLookupId个数不相等，请检查！\"); return false; } if (shieldLookupEles.length != shieldLookupShowNameEles.length) { ShieldJS.error(eleName + \"个数与shieldLookupName个数不相等，请检查！\"); return false; } } if(!$this.data(\"url\")){ //有链接才处理 dealEle = dealEle.not($this); ShieldJS.error(eleName + \"缺少data-url属性\"); ShieldJS.console(eleName + \"缺少data-url属性\"+$this.prop(\"outerHTML\")); return false; } }); } return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"1、弹出窗口，添加，显示，修改等；2、查找带回\" }, /** ajax请求,返回json格式，删除、更新状态等 */ shieldAjax : { expression : '.shieldAjax' ,deal : function(ele, contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ var $this = ele; if($this.data(\"url\")){ //有链接才处理 var successDo = ShieldJS.HtmlAction.successDo.shieldRefresh; if (hasAttr($this,\"successDo\")) { //保存成功后的处理 successDo = $this.attr(\"successDo\"); } if (successDo) { //回调 if(!ShieldJS.HtmlAction.checkSuccessDoMethodExist(successDo)){ return false; } } var url = $this.data(\"url\"); var viewTitle; if(hasAttr($this, ShieldJS.css.TITLE)){ viewTitle = $this.attr(ShieldJS.css.TITLE); } var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this, params); var runnext =true; //继续执行 if(viewTitle){ ShieldJS.confirm(\"确认提示\", viewTitle, function() { ShieldJS.HtmlAction.postData(url, params, contentE, searchForm, menuliSelect, shieldDialog, successDo, ShieldJS.HtmlAction.clickCallback($this)); }); } else { ShieldJS.HtmlAction.postData(url, params, contentE, searchForm, menuliSelect, shieldDialog, successDo, ShieldJS.HtmlAction.clickCallback($this)); } return false; } else { ShieldJS.error(\"shieldAjax元素缺少data-url属性！\"); ShieldJS.console(\"shieldAjax元素缺少data-url属性！\"+$this.prop(\"outerHTML\")); return false; } } ,fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ var dealMethod = this.deal; findAndMarkEle(contentE, this.expression).click(function() { var $this = $(this); dealMethod($this, contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog); return false; }); } ,description : \"ajax请求,返回json格式，删除、更新状态等\" }, /** ajax删除的处理 */ shieldDelete : { expression : '.shieldDelete', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ findAndMarkEle(contentE, this.expression).each(function() { var $this = $(this); if(!hasAttr($this, ShieldJS.css.TITLE)){ $this.attr(ShieldJS.css.TITLE, \"确定删除该信息吗？\"); } $this.click(function() { var $this = $(this); return ShieldJS.HtmlAction.HTMLEleActions.shieldAjax.deal($this, contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog); }); }); } ,description : \"ajax删除处理。\" }, /** 覆盖内容，类似于jQuery的jObj.load() */ shieldLoad : { expression : '.shieldLoad', fn : function(selectE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ var loadContent = function(ele) { var $this = ele; var url = $this.data(\"url\"); var targetEle = getjQueryObj($this.data(\"target\")); if (!targetEle) { targetEle = $this; //target如果没有则为自身 } var viewTitle; if(hasAttr($this,ShieldJS.css.TITLE)){ viewTitle = $this.attr(ShieldJS.css.TITLE); } var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this,params); // 执行方法 var doing = function() { targetEle.html(ShieldJS.loadingHtml); ShieldJS.ajax.post(url, params, function(data) { targetEle.html(data); ShieldJS.form.initSubmit(targetEle, function(formE, targetE, data){ //改写form的submit方法（util.js） }); //页面处理 ShieldJS.core.bindHtmlAction(targetEle, menuliSelect, navMenuSelect, searchForm); // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); }, null, null, true); } if (viewTitle) { ShieldJS.confirm(\"确认提示\", viewTitle, function() { doing(); }); }else { doing(); } }; selectE.each(function() { var $this = $(this); var autoload = \"false\"; if(hasAttr($this, \"autoload\")){ //autoLoad autoload = $this.attr(\"autoload\")||\"true\"; }else if(hasAttr($this, \"autoLoad\")){ //autoLoad autoload = $this.attr(\"autoLoad\")||\"true\"; } if (autoload==\"true\") { //自动加载 loadContent($this); }else { $this.click(function() { loadContent($this); // return false; }); } }); }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm){ var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"shieldLoad元素\"; if (dealEle.length &gt; 0) { dealEle.each(function(i, n){ var $this = $(this); if (!$this.data(\"url\")) { ShieldJS.error(eleName + \"未定义data-url：请添加该属性！\"); ShieldJS.console(eleName + \"未定义data-url：请添加该属性！\"+$this.prop(\"outerHTML\")); return false; } else if (hasAttr($this,\"data-target\") &amp;&amp; contentE.find($this.data(\"target\")).length == 0) { ShieldJS.error(eleName + \"目标元素未找到：请检查 data-target 的定义是否正确！\"); return false; } }); } return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"覆盖内容，类似于jQuery的jObj.load()\" }, /** a标签附加参数(如果不是新打开的页面,为Get方式提交需要注意参数长度) */ shieldA : { expression : '.shieldA', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ findAndMarkEle(contentE, this.expression).each(function() { var $this = $(this); if($this.data(\"url\")){ //有链接才处理 $this.click(function() { var url = $this.data(\"url\"); var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return true; } else { params = checkParams; } params = getParams($this, params); var method = $this.data(\"method\")||\"get\"; var target = $this.data(\"target\")||\"_blank\"; if (target == \"_blank\") { openNewPage($this, url, params); //shield.util.js 中的方法 // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); } else { var targetE = getjQueryObj(target); if (method == \"post\") { ShieldJS.ajax.post(targetE, url, params, function() { //内容区处理 if(!ShieldJS.core.contentAreaDeal(targetE, null, null)){ // return false; } // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); }); } else { ShieldJS.ajax.get(targetE, url, params, function() { //内容区处理 if(!ShieldJS.core.contentAreaDeal(targetE, null, null)){ // return false; } // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); }); } } // return false; }) } }); } ,description : \"a标签附加参数(如果不是新打开的页面,为Get方式提交需要注意参数长度)\" }, /** 打开链接 */ shieldOpenLink : { expression : '.shieldOpenLink', fn : function(selectE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ selectE.unbind(\"click\").click(function() { var $this = $(this); var linkSrcE = $this; var url = ''; if (hasAttr($this, \"baseOn\")) { //基于元素 var baseOnValue = $this.attr(\"baseOn\"); var baseOnValueArrs = baseOnValue.split(\"&gt;\"); if (baseOnValueArrs.length == 2) { linkSrcE = $this.closest(baseOnValueArrs[0]).find(baseOnValueArrs[1]); if (linkSrcE.is(\":input\")) { url = linkSrcE.val(); } else { url = linkSrcE.text(); } } } else { var prevE = $this.prev(); if (prevE.is(\":input\")) { // 类型为text的input或select if (prevE.is(\":text\") || prevE.is(\"select\")) { url = prevE.val(); } else { url = $this.text(); } } url = formatUrl(url); if (url == '') { ShieldJS.alert(\"消息提示\", '空连接,不能打开!', \"error\"); } else { $this.after(\"&lt;a href='\" + url + \"' target='_blank'&gt;&lt;/a&gt;\"); var a = $this.next(); a[0].click(); //直接用a.click()不执行 a.remove(); // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); } return false; }); }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm){ var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"shieldOpenLink元素\"; if (dealEle.length &gt; 0) { dealEle.each(function(i, n){ var $this = $(this); if (hasAttr($this, \"baseOn\")) { //基于元素 var baseOnValue = $this.attr(\"baseOn\"); var baseOnValueArrs = baseOnValue.split(\"&gt;\"); if (baseOnValueArrs.length == 2) { linkSrcE = $this.closest(baseOnValueArrs[0]).find(baseOnValueArrs[1]); if(linkSrcE.length == 0){ ShieldJS.error(eleName + \"未定义链接源元素：请检查baseOn的值定义是否正确（父元素选择器+“&gt;”+源元素选择器）\"); ShieldJS.console(eleName + \"未定义链接源元素：请检查baseOn的值定义是否正确（父元素选择器+“&gt;”+源元素选择器）\"+baseOnValue+$this.prop(\"outerHTML\")); return false; } } } }); } return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"打开链接\" }, /** 刷新 */ shieldRefresh : { expression : '.shieldRefresh', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ findAndMarkEle(contentE, this.expression).unbind(\"click\").click(function() { ShieldJS.HtmlAction.successDoMethod.shieldRefresh(contentE, searchForm, menuliSelect, shieldDialog); // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($(this)); return false; }); } ,description : \"刷新\" }, /** 带参数提交（form基础上点击不同按钮提交不同结果） */ shieldSubmit : { expression : '.shieldSubmit', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ findAndMarkEle(contentE, this.expression).unbind(\"click\").click(function() { var $this = $(this); var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this,params); var formE = $this.closest('form'); if (formE.length &gt; 0){ for(var key in params){ formE.find(\"input[name='\"+key+\"']\").val(params[key]); } if (!shieldDialog) { //dialog不存在时才处理，存在时默认处理 ShieldJS.form.initSubmit(contentE, function(formE, targetE, data){ // 初始化页面内容 ShieldJS.core.bindHtmlAction(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog); // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); }); } formE.submit(); } return false; }); } ,description : \"带参数提交（form基础上点击不同按钮提交不同结果）\" }, /** 回调 */ shieldDialogCallback : { expression : '.shieldDialogCallback', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ var shieldDialogCallbackEle = findAndMarkEle(contentE, this.expression); if (shieldDialogCallbackEle.length &gt; 0) { var methodName = shieldDialogCallbackEle.attr(\"callback\"); ShieldJS.shieldDialogCallback[methodName](contentE, shieldDialog); } } ,description : \"回调\" }, /** 弹出新窗口操作 */ shieldOpenWindow : { expression : 'a.shieldOpenWindow', fn : function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog){ findAndMarkEle(contentE, this.expression).unbind(\"click\").click(function() { var $this = $(this); var viewTitle = \"信息\"; if(hasAttr($this, ShieldJS.css.TITLE)){ viewTitle = $this.attr(ShieldJS.css.TITLE); } var viewWidth = 500; if(hasAttr($this, ShieldJS.css.WIDTH)){ viewWidth = $this.attr(ShieldJS.css.WIDTH); } if($this.data(\"url\")){ //有链接才处理 var url = $this.data(\"url\"); if(hasAttr($this, \"openUrl\")){ window.open($this.attr(\"openUrl\")); } var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this, params); setTimeout(function() { ShieldJS.openDialog(url, params, function(ele, dialog) { //提交的表单统一命名为saveForm var saveForm = ele.find('form.saveForm'); saveForm.unbind('submit').submit(function() { if(saveForm.kvvalid()){ //表单验证 if(hasAttr($this, \"submitTips\")){ setTimeout(function() { ele.find('.contentBody').html($this.attr('submitTips'));//改变了form结构 },10); } return true; } return false; //表单验证未通过 }); var shieldSubmitAction = ShieldJS.HtmlAction.HTMLEleActions[\"shieldSubmit\"]; if($.isFunction(shieldSubmitAction)){ shieldSubmitAction(saveForm); } //ShieldJS.core.bindHtmlAction(ele, menuliSelect, navMenuSelect, searchForm, dialog); //内部继续加载 // 自定义点击回调 ShieldJS.HtmlAction.clickCallback($this); }, viewTitle, viewWidth); },10); return false; } }); } ,description : \"弹出新窗口操作\" }, /** 图片上传 */ shieldImageUpload : { expression : 'input.shieldImageUpload', fn : function(selectE, menuliSelect, navMenuSelect, searchForm){ // 待实现 }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm){ var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"图片上传组件shieldImageUpload\"; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"图片上传\" }, /** 删除图片 */ shieldImgDelete : { expression : 'input.shieldImgDelete', fn : function(selectE, menuliSelect, navMenuSelect, searchForm){ // 待实现 }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm){//检查函数 var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"图片删除组件shieldImgDelete\"; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"删除图片\" }, /** 多图片上传插件 */ shieldMultiImgUpload : { expression : '.shieldMultiImgUpload', fn : function(selectE, menuliSelect, navMenuSelect, searchForm) { // 待实现 }, checkFn : function(contentE, menuliSelect, navMenuSelect, searchForm) { //检查函数 var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"图片上传组件shieldMultiImgUpload\"; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"多图片上传插件\" }, /** 下载附件 */ shieldDownload : { expression : '.shieldDownload', fn : function(selectE) { // 待实现 }, checkFn : function(contentE) { var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"下载附件元素shieldDownload\"; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"下载附件\" }, /** 关联其他元素的select * @example * //选择1时显示 id为dealBySpider的元素 选择2是显示id为yaunyinSpider的元素 * &lt;select id=\"state\" name=\"state\" class=\"shieldSelectRelated\"&gt; &lt;option value=\"\"&gt;--请选择--&lt;/option&gt; &lt;option value=\"1\" relatedTo=\"#dealBySpider\"&gt;通过&lt;/option&gt; &lt;option value=\"2\" relatedTo=\"#yaunyinSpider\"&gt;退回&lt;/option&gt; &lt;/select&gt; */ shieldSelectRelated : { expression : '.shieldSelectRelated', fn: function(selectE){ var shieldSelectRelated = selectE; shieldSelectRelated.change(function(){ var $this = $(this); setTimeout(function() { var selectVal = $this.val(); var paramNames = {id:\"id\",name:\"name\"}; //默认参数配置 if (hasAttr($this, \"relatedTo\")) { //select级别联动 var relatedTo = $this.attr(\"relatedTo\"); var relatedToE = getjQueryObj(relatedTo); var relatedUrl = $this.attr(\"relatedUrl\"); var paramAdapter = $this.attr(\"paramAdapter\"); var paramAdapters = paramAdapter.split(\"#\"); //#号分隔 for (var i=0;i&lt;paramAdapters.length;i++) { var paramName = paramAdapters[i]; if (paramName.indexOf(\"=\")!=-1) { var paramNames = paramName.split(\"=\"); //如果key与提交不一致用=号分隔 var paramsKey = paramNames[0]; var jsonResutlKey = paramNames[1]; paramNames[paramsKey] = jsonResutlKey; } else { paramNames[paramName] = paramName; } } //获取数据 if(relatedUrl.indexOf(\"{}\") != 0){ relatedUrl = relatedUrl.replace(\"{}\",selectVal); } var params={}; var checkParams = ShieldJS.HtmlAction.checkAnGetParamSelector($this, params); //参数选择器 if (!checkParams) { return false; } else { params = checkParams; } params = getParams($this, params); $.getJSON(relatedUrl, params, function(json) { var html = \"\"; if (json) { for ( var i = 0; i &lt; json.length; i++) { html += '&lt;option value=\"' + json[i][paramNames.id] + '\"&gt;'; html += json[i][paramNames.name] + '&lt;/option&gt;'; } } relatedToE.find(\"option:not(.noshield)\").remove(); relatedToE.append(html); }); } //option联动 $this.find(\"option\").each(function(){ var $thisOption = $(this); var opetionVal = $thisOption.val(); if (hasAttr($thisOption, \"relatedTo\")) { //有属性才处理 var relatedTo = $thisOption.attr(\"relatedTo\"); var relatedToE = getjQueryObj(relatedTo); if (opetionVal === selectVal) { relatedToE.find(\":input\").prop(\"disabled\",false); relatedToE.show(); } else { //表单设为不可用 relatedToE.find(\":input\").prop(\"disabled\",true); relatedToE.hide(); } } }); }, 1); //加定时器是因为通过utils赋值的select不加取不到值 }); shieldSelectRelated.triggerHandler(\"change\");//触发自定义change事件 }, checkFn : function(contentE) { //检查函数 var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"联动select元素shieldSelectRelated\"; if(dealEle.length &gt; 0 ) { dealEle.each(function(){ var $this = $(this); if (hasAttr($this,\"relatedTo\")) { //select级别的联动（区别于option级别） var relatedTo = $this.attr(\"relatedTo\"); var relatedToE = getjQueryObj(relatedTo); if (relatedToE.length == 0) { ShieldJS.error(eleName + \"联动元素未找到：请检查relatedTo属性是否定义错误！\"); ShieldJS.console(eleName + \"联动元素未找到：请检查relatedTo属性是否定义错误！\"+$this.prop(\"outerHTML\")); return false; } if (!hasAttr($this,\"relatedUrl\")) { ShieldJS.error(eleName + \"未定义数据获取地址：relatedUrl属性\"); ShieldJS.console(eleName + \"未定义数据获取地址：relatedUrl属性\"+$this.prop(\"outerHTML\")); return false; } if (!hasAttr($this,\"paramAdapter\")) { ShieldJS.error(eleName + \"未定义参数适配：paramAdapter属性\"); ShieldJS.console(eleName + \"未定义参数适配：paramAdapter属性\"+$this.prop(\"outerHTML\")); return false; } } }); }; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"关联其他元素的select\" }, /** 关联其他元素的checkbox或radio * @example * // shieldCheckedRelated关联操作checkbox或radio元素，relatedTo为关联到的元素，relatedToType=\"disabled\"表示将目标元素更改disabled属性（其他值：disabledAndHide及不写） * &lt;sapn style=\"float: left;padding: 3px;\"&gt;&lt;input type=\"checkbox\" id=\"acceptSetBtn\" class=\"shieldCheckedRelated\" relatedTo=\"#buySubmit\" relatedToType=\"disabled\"&gt;我已阅读并接受此规定&lt;/sapn&gt; * &lt;input type=\"button\" id=\"buySubmit\" class=\"shieldSubmit\" value=\"购买\" disabled=\"disabled\"&gt;*/ shieldCheckedRelated : { expression : '.shieldCheckedRelated', fn: function(selectE){ selectE.each(function(){ var thisSelectE = $(this); var shieldCheckedRelated = thisSelectE; var changeDealE; //如果是radio需处理为同一父类的radio if (shieldCheckedRelated.is(\":radio\")) { //单选框 var formE = shieldCheckedRelated.closest(\"form\"); changeDealE = formE.find(\":radio[name='\"+shieldCheckedRelated.attr(\"name\")+\"']\"); } if (!changeDealE) { changeDealE = shieldCheckedRelated; } changeDealE.each(function() { var bindE = $(this); if (!bindE.hasClass(\"shieldCheckedRelatedInit\")) { bindE.bind(\"change\",function(){ var $thisCheckedE = $(this); if (changeDealE) { //radio需处理同一父级的所有radio元素，否则点击其他的radio不会触发上一次选中radio的change事件 $thisCheckedE = changeDealE; } $thisCheckedE.filter(\":not(:checked)\").each(function(){ var $this = $(this); changeEvent($this); }); $thisCheckedE.filter(\":checked\").each(function(){ var $this = $(this); changeEvent($this); }); }); bindE.addClass(\"shieldCheckedRelatedInit\"); } }); shieldCheckedRelated.triggerHandler(\"change\");//触发自定义change事件 }); function showRelate2E(relatedToE, checked) { if (checked) { relatedToE.show(); } else { relatedToE.hide(); } } function changeEvent($this) { setTimeout(function() { var checked = $this.prop(\"checked\"); if (hasAttr($this, \"relatedTo\")) { //关联元素 var relatedTo = $this.attr(\"relatedTo\"); var relatedToE = getjQueryObj(relatedTo); if (hasAttr($this, \"relatedToType\")) { //定义关联状态 var relatedToType = $this.attr(\"relatedToType\").toLowerCase(); //转小写 if (relatedToType == \"disabled\") { //仅设为不可用 relatedToE.prop(\"disabled\",!checked); } else if (relatedToType == \"disabledandhide\") { //设为不可用并隐藏 relatedToE.prop(\"disabled\",!checked); relatedToE.find(\":input\").each(function() { var $thisInput = $(this); var disabled = $thisInput.prop(\"disabled\"); var data_enabled = $thisInput.data(\"enabled\"); var data_disabled = $thisInput.data(\"disabled\"); if (!data_enabled &amp;&amp; !data_disabled) { //未设置，则保存 if (disabled) { data_disabled = true; $thisInput.data(\"disabled\", true); } else { $thisInput.data(\"enabled\", true); } } if (checked) { //可用 $thisInput.prop(\"disabled\", data_disabled?true:false); } else { //不可用 $thisInput.prop(\"disabled\",!checked); } }); showRelate2E(relatedToE, checked); } else { //仅隐藏 showRelate2E(relatedToE, checked); } } else { //仅隐藏 showRelate2E(relatedToE, checked); } if (checked) { var datas = $this.data(); //用data存储 for ( var key in datas) { relatedToE.find('[name=\"'+key+'\"]').val(datas[key]); } } } }, 1); //加定时器是防止utils干扰 } }, checkFn : function(contentE) { //检查函数 var dealEle = findAndMarkEle(contentE, this.expression); var eleName = \"联动checkbox或radio元素shieldCheckedRelated\"; if(dealEle.length &gt; 0 ) { dealEle.each(function(){ var $this = $(this); if (hasAttr($this,\"relatedTo\")) { var relatedTo = $this.attr(\"relatedTo\"); var relatedToE = getjQueryObj(relatedTo); if (!relatedToE || relatedToE.length == 0) { ShieldJS.error(eleName + \"联动元素未找到：请检查relatedTo属性是否定义错误！\"); ShieldJS.console(eleName + \"联动元素未找到：请检查relatedTo属性是否定义错误！\"+$this.prop(\"outerHTML\")); return false; } } }); }; return dealEle.length &gt; 0 ? dealEle : false; } ,description : \"关联其他元素的checkbox或radio\" }, /** 全选 */ checkall : { expression : '#checkall', fn: function(contentE){ findAndMarkEle(contentE, this.expression).change(function() { var $this = $(this); var checked = $this.is(':checked'); var rangeE = $this.closest(\"table\"); if (hasAttr($this, \"rangeEle\")) { var rangeTo = $this.attr(\"rangeEle\"); rangeE = getjQueryObj(rangeTo); if (rangeE.length == 0) { ShieldJS.error(\"全选处理范围元素未找到：请检查rangeEle属性是否定义错误！\"); ShieldJS.console(\"全选处理范围元素未找到：请检查rangeEle属性是否定义错误！\"+$this.prop(\"outerHTML\")); return false; } } rangeE.find(':checkbox').each(function() { $(this).prop(\"checked\", checked); }); }); } ,description : \"全选\" }, /** 用于标记选中行，一般用于checkbox上用于选中行传参 */ shieldSelectRow : { expression : '.shieldSelectRow', fn: function(contentE){ findAndMarkEle(contentE, this.expression).change(function() { var $this = $(this); var checked = $this.is(':checked'); var checkClass = ShieldJS.HtmlAction.names.shieldSelectRowByshieldCheck; var rowEle = $this.closest(\"tr\"); rowEle.toggleClass(checkClass); }); } ,description : \"用于标记选中行，一般用于checkbox上用于选中行传参\" }, /** 用于表单自动提交 */ autoSubmitFormPlugin : { expression : '.autoSubmitForm_plugin', fn: function(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog) { findAndMarkEle(contentE, this.expression).each(function(i, n) { var $this = $(this); var successDo = ShieldJS.HtmlAction.successDo.shieldRefresh; // 默认提交成功后的回调方法 //ShieldJS.form.initSubmit($this, function(formE, targetE, data){ //改写form的submit方法（util.js） ShieldJS.core.bindHtmlAction(contentE, menuliSelect, navMenuSelect, searchForm, shieldDialog); //内部继续加载,已经默认实现 //ShieldJS.HtmlAction.formSubmitCallback(successDo, formE, targetE, data, menuliSelect, navMenuSelect, searchForm, shieldDialog); //}); $this.submit(); //页面处理 }); } ,description : \"自动提交表单\" }, /** 无数据tr处理 */ noDataTrPlugin : { expression : '.nodatatr_plugin', fn: function(contentE) { findAndMarkEle(contentE, this.expression).each(function(i, n) { var $this = $(this); var pervTr = $this.prev(); $this.find(\"th,td\").attr(\"colspan\", pervTr.find(\"th,td\").length); }); } ,description : \"无数据tr处理\" }, /** 用于显示所有已经注册的ShieldJS的html扩展动作方法 */ showAllShieldJS : { expression : '.showAllShieldJS', fn: function(contentE){ findAndMarkEle(contentE, this.expression).each(function(i, n) { var $this = $(this); var actions = $.extend({},ShieldJS.HtmlAction.HTMLEleActions); var tablecls = \"allShieldJSHtmlActions \"; //table的class tablecls += $this.data(\"class\")||\"\"; var extendUrl = $this.data(\"extendUrl\"); //扩展url，查看示例 var htmlStr = '&lt;table class=\"'+tablecls+'\"&gt;'+ '&lt;tr class=\"headertr\"&gt;&lt;th class=\"shieldjs_headertr_xh\"&gt;&lt;/th&gt;&lt;th class=\"shieldjs_headertr_method\"&gt;方法名&lt;/th&gt;&lt;th class=\"shieldjs_headertr_ex\"&gt;表达式&lt;/th&gt;&lt;th class=\"shieldjs_headertr_des\"&gt;描述&lt;/th&gt;'; if (extendUrl) { htmlStr += '&lt;th class=\"shieldjs_headertr_demo\"&gt;示例&lt;/th&gt;'; } htmlStr += '&lt;/tr&gt;'; var index = 0; for(var actionName in actions){ index++; htmlStr += '&lt;tr class=\"datatr\"&gt;&lt;td class=\"shieldjs_datatr_xh\"&gt;'+index+'&lt;/td&gt;&lt;td class=\"shieldjs_datatr_method\"&gt;'+actionName+'&lt;/td&gt;&lt;td class=\"shieldjs_datatr_ex\"&gt;'+(actions[actionName].expression||\"\")+'&lt;/td&gt;&lt;td class=\"shieldjs_datatr_des\"&gt;'+(actions[actionName].description||\"\")+'&lt;/td&gt;'; if (extendUrl) { htmlStr += '&lt;td class=\"shieldjs_datatr_demo\"&gt;&lt;a data-url=\"'+$this.data(\"extendUrl\")+actionName+'\" class=\"shieldDialog\" viewTitle=\"查看信息\" viewWidth=\"800\"&gt;查看示例&lt;/td&gt;'; } htmlStr += '&lt;/tr&gt;'; } htmlStr += '&lt;/table&gt;'; var tableE = $(htmlStr); tableE.find(\"td\").each(function(i, n) { $(this).data(\"html\", $(this).html()); }); if(extendUrl){ ShieldJS.core.bindHtmlAction([\"shieldDialogOrLookup\"], tableE); //加载shieldDialogOrLookup方法 } var _defaults = { /**前景色*/ foreground: 'red', /**背景色*/ background: 'yellow' }; //搜索 $(\".showAllShieldJSSearch\").on(\"keyup\", contentE, function() { var $search = $(this); var searchKey = $.trim($search.val()); if (searchKey) { var options = $.extend(true, _defaults, getSettings($search)); tableE.find(\"tr.datatr\").hide(); tableE.find(\"tr.datatr\").filter(function() { if ($(this).text().toLowerCase().indexOf($search.val().toLowerCase())!=-1) { var reg = new RegExp(\"(\"+$search.val()+\")\", \"gi\"); //全局并忽略大小写 $(this).find(\"td\").not(\".shieldjs_datatr_demo\").each(function(i, n) { //排除示例 var newstr = $(n).data(\"html\").replace(reg, '&lt;strong style=\"background-color: '+options.background+';color: '+options.foreground+';\"&gt;$1&lt;/strong&gt;'); $(n).html(newstr); }); return true; } return false; }).show(); } else { tableE.find(\"tr.datatr\").show().find(\"td\").not(\".shieldjs_datatr_demo\").each(function(i, n) { $(this).html($(this).data(\"html\")); }); } }); $this.append(tableE); }); } ,description : \"展示所有的注册方法\" } }, /** 添加htmlEle动作处理函数 * @param HTMLEleName {String} 方法名称 * @param expression {String} 表单式 * @param fn {String} 处理函数 * @param checkFn {String} 检查函数【可无】 * @param description {String} 方法描述 */ addHTMLEleAction : function (HTMLEleName, expression, fn, checkFn, description) { if(this.HTMLEleActions[HTMLEleName]){ ShieldJS.debug(HTMLEleName + \"动作处理方法被覆盖！\"); } // 复制对象 var copiedObject = $.extend({}, this.HTMLEleActions[HTMLEleName]); var expressionV = arguments[1]; //重载，expression可能不存在 var indexRemove = 0; if ($.isFunction(expression)) { expressionV = \"\"; indexRemove++; } var fnV = arguments[2-indexRemove]; //重载，checkFn函数可能不存在 var checkFnV = arguments[3-indexRemove]; var descriptionV = arguments[4-indexRemove]; if (typeof(checkFnV)==\"string\") { descriptionV = checkFnV; } this.HTMLEleActions[HTMLEleName] = { expression : expressionV || \"\" //表达式 ,fn:fnV //处理函数 ,checkFn:checkFnV //检查函数，是否缺少属性等，如果不合法返回false ,description : descriptionV || copiedObject.description //方法描述 }; } } })(jQuery); × Search results Close "},"shield.main.js.html":{"id":"shield.main.js.html","title":"Source: shield.main.js","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Source: shield.main.js /** * ShieldJS主类，定义了框架的一些主要属性及方法 * @author Kevin Lv &lt;donggongai@126.com&gt; * @class * @version 2.1.0 * @date 2019-1-25 */ var ShieldJS = { /** ShieldJS的版本号 @type String @const */ version:\"2.0\", /** 键盘按键的值的常量 @enum {int} @readonly */ keyCode: { ENTER: 13, ESC: 27, END: 35, HOME: 36, SHIFT: 16, TAB: 9, BLANK: 32, LEFT: 37, RIGHT: 39, UP: 38, DOWN: 40, DELETE: 46, BACKSPACE:8 } /** 框架内置的几种常用样式名 @enum {String} @readonly */ ,css:{ TITLE:'viewTitle',WIDTH:'viewWidth',HEIGHT:'viewHeight', /** 显示 */ SHOW:'shield-show', /** 选中*/ THIS:'shield-this', /** 禁用 */ DISABLED:'shield-disabled' } /** 框架核心方法 * @class ShieldJS.core */ ,core:{} /** 框架html动作绑定方法 * @class ShieldJS.HtmlAction */ ,HtmlAction:{} /** 框架消息模板 @type Key-Value @final */ ,_msg:{} /** 根据key及传入参数获取模板信息 @param key {String} 内置消息模板的key @param args {Array(Object)} 替换模板变量的参数 @returns {String} 替换参数后的模板信息 */ ,msg : function(key, args){ var _format = function(str,args) { args = args || []; var result = str || \"\"; for (var i = 0; i &lt; args.length; i++){ result = result.replace(new RegExp(\"\\\\{\" + i + \"\\\\}\", \"g\"), args[i]); } return result; } return _format(this._msg[key], args); } /** 内部变量设置（可设置是否调试模式） @enum {Boolean} @readonly */ ,_set:{ /** 调试模式，部署时关闭 */ debug:true } /** 调试输出是否输出堆栈信息 @param msg {Boolean} 是否输出堆栈信息 */ ,debugTrace : false /** 调试输出 @param msg {String} 调试信息 @param trace {Boolean} 输出堆栈信息 */ ,debug : function(msg, trace){ if (this._set.debug) { if (typeof(console) != \"undefined\"){ var logInfo = new Date()+\" \"+msg; if (trace || ShieldJS.debugTrace) { logInfo += \" by:\" + printCallStack(); } console.log(logInfo); } // else alert(msg); } } ,console : function(msg){ if (typeof(console) != \"undefined\"){ var logInfo = new Date()+\" \"+msg; console.log(logInfo); } } /** 错误输出 @param msg {String} 错误信息 */ ,error : function(msg){ this.alert(\"错误信息\", msg, \"error\"); } /** 设置ShieldJS的版本号 @param suffix {String} 版本号后缀 */ ,setVersion: function(suffix) { if (this.version &amp;&amp; this.version != \"2.0\") { alert(\"引入了多个shieldjs扩展包，版本号:\"+this.version+\" 与 \"+suffix); return; } this.version = this.version+\"-\"+suffix; } /** 加载文件 @param path {String} 文件路径 @param success {Function} 加载成功后的回调方法 */ ,loadfile : function(path, success) { //加载文件 var data = \"\"; $.ajax({ url: path, async: false, //同步 data: {t:'2018011601'}, success: function(content){ // content就为文件的文本内容了,文件的编码最好保存成utf-8 success(content); } }); } /** 当前js文件的路径，通过{@link ShieldJS.getJsPath}获取 @type String @see ShieldJS.getJsPath */ ,jsPath :\"\" /** 获取当前js文件的路径 * @see {@link ShieldJS.jsPath} * @returns {String} 当前js文件的路径 */ ,getJsPath : function() { if (!this.jsPath) { var js = document.scripts; this.jsPath = js[js.length-1].src.substring(0,js[js.length-1].src.lastIndexOf(\"/\")+1); } return this.jsPath; } /** 提示框，可以覆盖，默认采用alert，type字符型（success、error、info、warning） * @param title {String} 标题 * @param message {String} 提示内容 * @param type {String} 提示类型包括：success、error、info、warning4种 */ ,alert : function(title, message, type){ alert(message); } /** 确认框 * @param title {String} 标题 * @param message {String} 提示内容 * @param ok {String} 确定后的回调方法 * @param cancel {String} 取消后的回调方法 */ ,confirm : function(title, message, ok, cancel){ if (confirm(message)) { ok(); } else { cancel(); } } /** 框架封装的ajax方法 * @class ShieldJS.ajax */ ,ajax : { /** ajax请求对象 */ requests : { singleRequest : null, mutiRequest : null, clearRequest : function() { this.singleRequest = null; this.mutiRequest = null; } }, abortLastReq : function() { if (this.requests &amp;&amp; this.requests.singleRequest) { this.requests.singleRequest.abort(); this.requests.singleRequest = null; //ShieldJS.debug(\"abort ajax request\"); } }, /** ajax全局处理方法，可覆盖 */ global : { error : function(response, textStatus, errorThrown) { // 第一个参数 response（jqXHR ） 在jQuery1.5版本以后则开始使用jqXHR对象，该对象是一个超集，就是该对象不仅包括XMLHttpRequest对象，还包含其他更多的详细属性和信息 // readyState :当前状态,0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成。 // status ：返回的HTTP状态码，比如常见的404,500等错误代码。 // statusText ：对应状态码的错误信息，比如404错误信息是not found,500是Internal Server Error。 // responseText ：服务器响应返回的文本信息 // 第二个参数 textStatus（String）：返回的是字符串类型，表示返回的状态，根据服务器不同的错误可能返回下面这些信息：\"timeout\"（超时）, \"error\"（错误）, \"abort\"(中止), \"parsererror\"（解析错误），还有可能返回空值。 // 第三个参数 errorThrown（String）：也是字符串类型，表示服务器抛出返回的错误信息，如果产生的是HTTP错误，那么返回的信息就是HTTP状态码对应的错误信息，比如404的Not Found,500错误的Internal Server Error。 var responseText = response.responseText; ShieldJS.debug(responseText); var contentType = response.getResponseHeader(\"content-type\") || \"\"; ShieldJS.checkError(responseText, contentType); if (clickBtn) { clickBtn.removeAttr('disabled'); } if (ShieldJS.contentMainE.length &gt; 0) { ShieldJS.contentMainE.find(\":button\").prop(\"disabled\", false); } }, complete : function(response, textStatus) { ShieldJS.ajax.requests.clearRequest(); // if (response.status == 200) { // } //不使用 findAndMarkEle 防止多加 if (ShieldJS.contentMainE &amp;&amp; ShieldJS.contentMainE.length &gt; 0) { ShieldJS.contentMainE.find(\"input[type=button],input[type=submit],input[type=reset]\") .not(\".noclass,.ke-button\").removeClass(\"button\").addClass(\"button\"); ShieldJS.contentMainE.find(\"button\").not(\".noclass\").removeClass(\"button1\").addClass(\"button1\"); } if (ShieldJS.avtiveTabContentE &amp;&amp; ShieldJS.avtiveTabContentE.length &gt; 0) { //tab内容区 ShieldJS.avtiveTabContentE.find(\"input[type=button],input[type=submit],input[type=reset]\") .not(\".noclass,.ke-button\").removeClass(\"button\").addClass(\"button\"); ShieldJS.avtiveTabContentE.find(\"button\").not(\".noclass\").removeClass(\"button1\").addClass(\"button1\"); } if (ShieldJS.dialogE &amp;&amp; ShieldJS.dialogE.length &gt; 0) { //弹出框 ShieldJS.dialogE.find(\"input[type=button],input[type=submit],input[type=reset]\") .not(\".noclass,.ke-button\").removeClass(\"button\").addClass(\"button\"); ShieldJS.dialogE.find(\"button\").not(\".noclass\").removeClass(\"button1\").addClass(\"button1\"); } } }, dealParamsAjax : function(method, ele, url, params, success, error, dataType, async) { // shift arguments if data argument was omitted if (typeof(ele) == \"string\") { async = dataType; dataType = error; error = success; success = params; params = url; url = ele; ele = undefined; } return this.ajax(ele, url, params, success, error, method, dataType, async); }, /** ajax请求 * @param ele {jQueryObj} 发起请求的jQuery对象 * @param url {String} 请求链接 * @param params {Object} 参数,json格式或者字符串格式 * @param success {Function} 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 * @param error {Function} 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 * @param method {String} 请求方法 * @param dataType {String} 返回结果类型 * @param async {Boolean} 是否是异步请求 */ ajax : function(ele, url, params, success, error, method, dataType, async) { if (typeof(ele) == \"string\") { async = dataType; dataType = error; error = success; success = params; params = url; url = ele; ele = undefined; } disabledBtn(); if (!params) { params = {}; } params.r = new Date().getTime(); if (ele) { ele.html(ShieldJS.loadingHtml); } if (params.singleRequest) { this.abortLastReq(); } if (async == null) { async = true; } var request = $.ajax({ url : url, type: method, dataType: dataType, data : params, traditional : true, async : async, //异步(不写默认值ie下有问题) beforeSend:function(XMLHttpRequest){ var tokenEle = $(\"#csrfTokenInput:last\"); if (ShieldJS.contentMainE.find(\"iframe\").length&gt;0) { //如果有iframe则取iframe里的 tokenEle = tokenEle.add(ShieldJS.contentMainE.find(\"iframe\").contents().find(\":root\").find(\"#csrfTokenInput:last\")); } if (tokenEle.length &gt; 0) { var tokenEle = tokenEle.last(); XMLHttpRequest.setRequestHeader(tokenEle[0].name, tokenEle.val()); } // 显示遮罩层 //App.blockUI({target : ele,animate : true}); }, success : function(htmlData, textStatus, jqXHR) { undisabledBtn(); if (clickBtn) { clickBtn.removeAttr('disabled'); } var contentType = jqXHR.getResponseHeader(\"content-type\") || \"\"; if (ShieldJS.checkError(htmlData, contentType)) { if (ele) { ele.html(htmlData); } // initPage();// 初始化页面 if (typeof success == 'function') { success(htmlData); } } else { if (ele) { ele.html(''); } if (typeof error == 'function') { error(htmlData); } } }, complete:function(response, textStatus){ //请求结束方法增强处理 ,隐藏遮罩层 //App.unblockUI(ele); ShieldJS.ajax.global.complete(response, textStatus); }, error: function (response, textStatus, errorThrown) { ShieldJS.ajax.global.error(response, textStatus, errorThrown); } }); if (params.mutiRequest) { this.requests.mutiRequest = request; } else { this.requests.singleRequest = request; } }, /** ajax发起get请求 * @param ele {jQueryObj} 发起请求的jQuery对象 * @param url {String} 请求链接 * @param params {Object} 参数,json格式或者字符串格式 * @param success {Function} 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 * @param error {Function} 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 * @param dataType {String} 返回结果类型，参考jQuery的ajax说明 * @param async {Boolean} 是否是异步请求 */ get : function(ele, url, params, success, error, dataType, async) { this.dealParamsAjax(\"get\", ele, url, params, success, error, dataType, async); } /** ajax发起post请求 * @param ele {jQueryObj} 发起请求的jQuery对象【非必需】 * @param url {String} 请求链接 * @param params {Object} 参数,json格式或者字符串格式 * @param success {jQueryObj} 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 * @param error {jQueryObj} 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 * @param dataType {jQueryObj} 返回结果类型，参考jQuery的ajax说明 * @param async {jQueryObj} 是否是异步请求 */ ,post : function(ele, url, params, success, error, dataType, async) { this.dealParamsAjax(\"post\", ele, url, params, success, error, dataType, async); } /** ajax获取json对象 * @param url {String} 请求链接 * @param params {Object} 参数,json格式或者字符串格式 * @param success {Function} 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 * @param error {Function} 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 * @param async {Boolean} 是否是异步请求 */ ,getJSON : function(url, params, success, error, async) { this.dealParamsAjax(\"get\", null, url, params, success, error, \"json\", async); } } ,dataExtends : {needLogin : false} /** 返回值统一方法，判断有无错误（TODO方法名待修改） * @param data {Object} 验证对象，可能为json对象也可能为html文本，json对象示例{\"success\":true,\"message\":\"提示信息\"} * @param contentType {String} 返回结果类型 * @returns {Boolean} 验证通过时返回true，否则返回false */ ,checkError : function(data, contentType) { // 为json格式 var json; if (typeof data == 'object') { //js对象 json = data; } else { //一般为string try { json = $.parseJSON(data); } catch (e) { json = ''; } } if (json) { if (json.refresh) { //刷新 $(\"[type='submit']\").closest(\"form.searchForm\").submit(); } if (json.data &amp;&amp; json.data.href &amp;&amp; json.data.target &amp;&amp; ShieldJS.contentMainE) { //含有附加内容,此处是链接 ShieldJS.contentMainE.find(json.data.target).show().attr(\"href\", json.data.href); } if (json.message &amp;&amp; json.success) { ShieldJS.alert(\"消息提示\", json.message, \"success\"); } if (json.success == false) { //失败 var logintype = json.data&amp;&amp;json.data.logintype; if (logintype) { if (logintype == 'redirect') { window.location.href = json.data.loginurl; } else if(logintype == 'reload') { window.location.reload(); }else { ShieldJS.checkErrorLoginExtend(json, data); } } else { if (json.message &amp;&amp; !json.success) { ShieldJS.alert(\"消息提示\", json.message, \"error\"); } } return false; } } return true; } /** 检查返回数据登录的扩展方法（子类可覆盖） * @param data {JSON} 返回的对象，一般为json格式 * @param data {Object} 返回的原始对象，一般为string或者json格式 * @returns {Boolean} 返回true继续执行后续方法，返回false则不再执行后续方法 */ ,checkErrorLoginExtend : function(json, data) { //扩展方法 if (!ShieldJS.dataExtends.needLogin) { ShieldJS.dataExtends.needLogin = true; ShieldJS.openDialog(json.data.loginurl, {}, function(ele, dialog) { ele.data(\"extendRemove\", function(index){ //扩展弹出框的remove方法 ShieldJS.dataExtends.needLogin = false; }); ShieldJS.form.initSubmit(ele, function(formE, targetE, data) {//成功后 dialog.remove(); //关闭弹出框 if (!ShieldJS.dialogE) { //非弹出框则只执行刷新 var searchForm = $(\"[type='submit']\").closest(\"form.searchForm\"); if (searchForm.length &gt; 0) { searchForm.submit(); } else { ShieldJS.activeSiderE.click(); } } }); }, \"登录\", 400, 500, null, \"iframe\", {\"onlyOne\":true}); if (json.message &amp;&amp; !json.success) { ShieldJS.alert(\"消息提示\", json.message, \"error\"); } } return true; } /** 窗口resize的处理事件集合（使用时 winResizes[\"方法名\"]=function） @type Key-Value */ ,winResizes : {} /** document点击的处理事件集合（使用时 docClicks[\"方法名\"]=function） @type Key-Value */ ,docClicks : {} /** 弹出层，依赖于layer js * @constructor ShieldJS.dialog * @example 示例： * var dialog = new ShieldJS.dialog(); * dialog.index = 1; * dialog.remove(); */ ,dialog : { /** 弹出框元素对象 @type jQueryObject */ dialogO : null, init : function (ele, index, title, width, height, preEle, preEleIndex, onlyOne){ var dialog = new Dialog(); dialog.init(ele, index, width, height, preEle, preEleIndex); dialog.title = title; this.dialogO = dialog; ShieldJS.dialogs.put(index, dialog); }, /** 移除弹出框 */ remove : function (indexV, callback){ var dialogIndex = this.dialogO.index; if (indexV) { dialogIndex = indexV; } var dialogObj = ShieldJS.dialogs.get(dialogIndex); ShieldJS.winResizes[\"dialogResize\"+dialogIndex] = null; //resize置空 var curDialogE = ShieldJS.dialogE; if (curDialogE.data(\"extendRemove\")) { curDialogE.data(\"extendRemove\")(indexV); } ShieldJS.dialog.removeCallback(curDialogE); console.log(new Date()+\"remove dialog\"+\" \"+dialogIndex); if (dialogObj) { ShieldJS.dialogE = dialogObj.preEle; var index = dialogObj.preEleIndex; var perDialog = ShieldJS.dialogs.get(index); this.dialogO = perDialog; } else { ShieldJS.dialogE = null; this.index = -1; } if (dialogObj &amp;&amp; dialogObj.index) { ShieldJS.dialogs.remove(dialogObj.index); layer.close(dialogObj.index); //此时你只需要把获得的index，轻轻地赋予layer.close即可 } else { ShieldJS.dialogs.remove(layer.index); layer.close(layer.index); //它获取的始终是最新弹出的某个层，值是由layer内部动态递增计算的 } }, removeCallback : function(dialogE) { // 具体实现中扩展 }, /** 重置宽高 * @type jQueryObject */ resize : function(layerIndex, layerInitWidth, layerInitHeight) { if (!layerInitWidth) { var perDialog = ShieldJS.dialogs.get(layerIndex); if (perDialog &amp;&amp; perDialog.ele) { layerInitWidth = perDialog.ele.width(); //获取元素的宽度 } } var docWidth = $(window).width(); //可视区域，document为全部区域 var docHeight = $(window).height(); //可视区域，document为全部区域 var minWidth = layerInitWidth &gt; docWidth ? docWidth : layerInitWidth; var minHeight = layerInitHeight &gt; docHeight ? docHeight : layerInitHeight; // console.log(\"resize\"+layerIndex+\" \"+layerInitWidth+\" \"+ layerInitHeight+\" \"+docWidth+\" \"+docHeight); var style = {height:layerInitHeight, width: layerInitWidth}; if (layerInitHeight &gt; docHeight) { style.top = 5; style.height = minHeight -10; } else if (layerInitWidth &gt; docWidth) { style.width = minWidth; } this.width = style.width; this.heigth = style.height; layer.style(layerIndex, style); }, /** 打开弹出框 * @param url {String} 弹出框的链接 * @param params {Object} 参数,json格式或者字符串格式 * @param callback {Function} 打开弹出框后的回调 * @param title {String} 弹出框标题 * @param width {Number} 弹出框宽度 * @param height {Number} 弹出框高度 * @param async {Boolean} 是否异步 * @param relType {String} 关联类型，可以为iframe或者不填 * @param options {Json} 扩展属性 */ open : function(url, params, callback, title, width, height, async, relType, options) { params.singleRequest = true; //单个请求 var dialog= this; var onlyOne = options.onlyOne||false; // try { // layer; // } catch (e) { // ShieldJS.error(\"缺少依赖JS库：layer！\"); // return false; // } if(typeof layer == \"undefined\" ){ ShieldJS.error(\"缺少依赖JS库：layer！\"); return false; } var openType = 1; if (relType &amp;&amp; relType==\"iframe\") { openType = 2; } if (openType == 2) { //iframe var index = layer.open({ //可传入的值有：0（信息框，默认）1（页面层）2（iframe层,content位url）3（加载层）4（tips层） type:2, skin: 'shieldjs-custom-layer', //加上边框layui-layer-rim title: title, area: [width+'px', height+'px'], fix: false, //不固定 shadeClose: false, shade: 0.5, scrollbar: false, content: url, success: function(layero, index) { layer.iframeAuto(index); //高度自适应 /*windows窗口变化时重置大小,经测试放到外面会有延时，影响展示效果 */ ShieldJS.winResizes[\"dialogResize\"+index] = function() { layer.iframeAuto(index); //高度自适应 }; setTimeout(function(){ dialog.dialogO.ele = $('#layui-layer'+index).find(\"iframe\").contents().find(\":root\"); //搜索根元素 ShieldJS.dialogE = dialog.dialogO.ele; if (callback) { callback(dialog.dialogO.ele, dialog); } if (ShieldJS.core) { ShieldJS.core.bindHtmlAction(dialog.dialogO.ele, null, null, options.searchForm, dialog); //内部继续加载 } dialog.width = layero.width(); dialog.height = layero.height(); }, 200); }, cancel: function(index, layero){ dialog.remove(); return true; } }); dialog.init($('#layui-layer'+index), index, title, width, height, ShieldJS.dialogE, dialog.dialogO?dialog.dialogO.index:null, onlyOne); //初始化 ShieldJS.dialogE = dialog.dialogO.ele; // $('#layui-layer'+index).find(\"iframe\").load(function() { //iframe加载完成后 // dialog.dialogO.ele = $(this).contents().find(\":root\"); //搜索根元素 // ShieldJS.dialogE = dialog.dialogO.ele; // if (callback) { // callback(dialog.dialogO.ele, dialog); // } // ShieldJS.core.bindHtmlAction(dialog.dialogO.ele, null, null, null, dialog); //内部继续加载 // dialog.width = $(this).width(); // dialog.height = $(this).height(); // }); } else { ShieldJS.ajax.get(url, params, function(data) { var winHeight = $(window).height(); var index = layer.open({ type: openType, // moveOut: true, // maxmin: true, skin: 'shieldjs-custom-layer', //加上边框layui-layer-rim maxHeight : winHeight-14, //最大高度，只有当高度自适应时，设定才有效。 area: (width ? width : 500)+'px', //宽度 title : title, content: data.replace(/(^\\s*)|(\\s*$)/g, \"\"), success: function(layero, index) { /*setTimeout(function(){ //延时更新窗口大小，防止有其他元素更改高度宽度 var layerIndex = index; //获取当前窗口的索引 var layerInitWidth = $(\"#layui-layer\"+index).width(); //获取layer的宽度 var layerInitHeight = $(\"#layui-layer\"+index).height(); //获取layer的高度 dialog.width = layerInitWidth; dialog.height = layerInitHeight; ShieldJS.dialog.resize(layerIndex, layerInitWidth, layerInitHeight); //调用resizeLayer方法 }, 200);*/ setTimeout(function(){ if (callback) { callback(dialog.dialogO.ele, dialog, index); } if (ShieldJS.core.bindHtmlAction) { ShieldJS.core.bindHtmlAction(dialog.dialogO.ele, null, null, null, dialog); //内部继续加载 } }, 200); }, cancel: function(index, layero){ dialog.remove(); return true; } }); dialog.init($('#layui-layer'+index), index, title, null, null, ShieldJS.dialogE, dialog.dialogO?dialog.dialogO.index:null, onlyOne); //初始化 ShieldJS.dialogE = dialog.dialogO.ele; var dialogContentE = dialog.dialogO.ele.find(\".layui-layer-content\"); var titleHeight = dialog.dialogO.ele.find(\".layui-layer-title\").height(); /*自身内容发生变化时，layui-layer-content为dialog的内容区*/ dialogContentE.resize(function() { console.log(dialogContentE[0].scrollHeight+titleHeight); setTimeout(function(){ dialog.resize(index, null, dialogContentE[0].scrollHeight+titleHeight); //调用resize方法 }, 100); }); /*windows窗口变化时重置大小*/ ShieldJS.winResizes[\"dialogResize\"+index] = function() { //宽度处理有问题 // console.log(\"resize\"+index+\" \"+dialog.dialogO.ele.width()+\" \"+ dialog.dialogO.ele.height()+\" scroll:\"+ dialog.dialogO.ele.find(\".layui-layer-content\")[0].scrollHeight ); // ShieldJS.dialogE.find(\".layui-layer-content\")[0].scrollHeight 为div的实际高度，如有滚动条时获取真实高度 dialog.resize(index, null, dialogContentE[0].scrollHeight+titleHeight); //调用resize方法 }; }, function(data) { var json; if (typeof data == 'object') { //js对象 json = data; } else { //一般为string try { json = $.parseJSON(data); } catch (e) { json = ''; } } ShieldJS.error(json.message||\"打开弹出框出错！\" + url + \" params: \"+params); }, null, async); } } } /** 弹出框Map,key为下标，value为dialog对象 @type Map */ ,dialogs : new Map() /** 打开弹出框(实际调用的是dialog.open) * @param url {String} 弹出框的链接 * @param params {Object} 参数,json格式或者字符串格式 * @param callback {Function} 打开弹出框后的回调 * @param title {String} 弹出框标题 * @param width {Number} 弹出框宽度 * @param height {Number} 弹出框高度 * @param async {Boolean} 是否异步 * @param relType {String} 关联类型，可以为iframe或者不填 * @param options {Json} 扩展属性 */ ,openDialog : function(url, params, callback, title, width, height, async, relType, options) { options = options||{}; ShieldJS.dialog.open(url, params, callback, title, width, height, async, relType, options); } ,getDialogs : function(title) { var dialogsGet = new Array(); for(var dialog in ShieldJS.dialogs.values()){ if (dialog.title == title) { dialogsGet.push(dialog); //添加到 dialogsGet 的尾部 } } return dialogsGet; } /** 框架的form处理 * @constructor ShieldJS.form */ ,form : { /** 初始化当前元素的表单 * @param ele {jQueryObj} 需要处理的jQuery对象 * @param callback {Function} 表单提交后的回调 (formE, targetE, data) * @param checkFn {Function} 对表单进行检查筛选，返回true表示通过 */ initSubmit : function(ele, callback, checkFn) { var ShieldJSForm = this; if (ele.length &gt; 0) { var formEs = (ele[0].tagName != 'FORM') ? ele.find('form') : ele; formEs.each(function(i, n) { ShieldJSForm.initOneSubmit($(this), callback, checkFn); }); } }, /** 初始化单个表单 * @param formE {jQueryObj} form标签的jQuery格式对象 * @param callback {Function} 表单提交后的回调 * @param checkFn {Function} 对表单进行检查筛选，返回true表示通过 */ initOneSubmit : function(formE, callback, checkFn) { //_blank 打开新窗口的不处理 var target = \"\"; if(hasAttr(formE,\"target\")){ target = formE.attr(\"target\"); } if (target != \"_blank\") { formE.unbind('submit').submit(function() { if(!target){ target = formE.attr('shieldTarget'); //shieldJs } var targetE = target ? findEle(formE, target) : null; //修改 if (targetE &amp;&amp; targetE.length == 0) { targetE = target ? $(target) : null; //修改 if (targetE.length &gt; 1) { ShieldJS.error(\"表单提交目标对象超过1个，不执行覆盖操作！target: \"+target + \" 数目：\"+targetE.length); targetE = null; } } clickBtn = formE.find(':submit,.shieldSubmit'); if (!clickBtn.is(':disabled')) { var formTemp = []; var options = { beforeSubmit : function() { if (ShieldJS.form.validate(formE)) { if ((typeof checkFn != 'function' || checkFn(formE))) { if (targetE) { targetE.html(ShieldJS.loadingHtml); } // 防止重复提交 clickBtn.attr('disabled', 'disabled'); // 清除嵌套表单 formE.find('form').each(function() { var formE = $(this); formTemp.push([ formE.prev(), formE ]); formE.remove(); }); return true; } } return false; }, success : function(data, textStatus, jqXHR) { clickBtn.removeAttr('disabled'); var contentType = jqXHR.getResponseHeader(\"content-type\") || \"\"; if (ShieldJS.checkError(data, contentType)) { //检查是否成功 if (targetE) { targetE.html(data); } if (typeof callback == 'function') { //成功后的回调 callback(formE, targetE, data); } if (typeof formE.attr(\"callback\") != 'undefined') { var method = formE.attr(\"callback\"); if($.isFunction(methods[method])){ methods[method](targetE); } } } // 还原嵌套表单 for ( var i = 0; i &lt; formTemp.length; i++) { var obj = formTemp[i]; if (obj[0].append) { obj[0].after(obj[1]); } } } }; setTimeout(function() { formE.ajaxSubmit(options); }, 1); } return false; }); } this.initOneSubmitExtend(formE, target); }, /** 初始化单个表单的扩展方法（默认将当前页码设置为1） * @param formE {jQueryObj} form标签的jQuery格式对象 * @param target {String} 表单提交后目标对象 */ initOneSubmitExtend : function(formE, target) { //扩展方法 formE.find(\":submit\").click(function() { //执行查询时把页数设置为1 var pageNum = formE.find(\".pageNum\"); if (pageNum.length &gt; 0) { pageNum.val(1); } }); }, /** 表单验证 * @param formE {jQueryObj} 待验证的form对象 * @returns {Boolean} 验证通过时返回true，否则返回false */ validate : function(formE) { //扩展方法 var options = {}; options = getExtendSettings(formE, options); return formE.kvvalid(options); } } /** 加载中的html代码 @type String */ ,loadingHtml:\"加载中……\" /** 头部信息区 @type jQueryObject */ ,topBarE : null /** 头部菜单区 @type jQueryObject */ ,topMenuE : null /** 选中的头部菜单区 @type jQueryObject */ ,activeTopMenuE : null /** 左侧栏 @type jQueryObject */ ,siderE : null /** 左侧栏选中区 @type jQueryObject */ ,activeSiderE : null /** 主内容区（不变） @type jQueryObject */ ,contentMainE: null /** 当前可见的主内容区tab内容区 @type jQueryObject */ ,avtiveTabContentE : null /** 当前可见的主内容区tab标题 @type jQueryObject */ ,activeTabTitleE : null /** 弹出框 ，其他可在实现框架内扩展 @type jQueryObject */ ,dialogE : null /** shieldDialog回调方法 @type Key-Value */ ,shieldDialogCallback : {} /** 初始化扩展方法 @param options 配置文件，参考shield.core.js的参数配置 @see shield.core.js#_defaults */ ,initExtend : function(options){ } /** 初始化方法，使用时直接调用该方法 @param options 配置文件，参考shield.core.js的参数配置 @see shield.core.js#_defaults */ ,init : function(options){ // this.initExtend(options); ShieldJS.core.main(options); } }; ShieldJS.getJsPath(); var request; var clickBtn; var abortLastReq = function() { if (request) { request.abort(); request = null; } }; //统一AJAX处理 $.ajaxSetup({ //具体实现优先，没有具体实现时才调用该方法 error : function(response, textStatus, errorThrown) { ShieldJS.ajax.global.error(response, textStatus, errorThrown); return false; }, complete : function(response, textStatus) { ShieldJS.ajax.global.complete(response, textStatus); } }); //button不可用 var disabledBtn = function() { if(ShieldJS.contentMainE &amp;&amp; ShieldJS.contentMainE.length &gt; 0){ ShieldJS.contentMainE.find(\":button:not(.ignoredis)\").prop(\"disabled\",true); } if(ShieldJS.dialogE &amp;&amp; ShieldJS.dialogE.length &gt; 0){ ShieldJS.dialogE.find(\":button:not(.ignoredis)\").prop(\"disabled\",true); } }; //button恢复可用 var undisabledBtn = function() { if(ShieldJS.contentMainE &amp;&amp; ShieldJS.contentMainE.length &gt; 0){ ShieldJS.contentMainE.find(\":button:not(.ignoredis)\").prop(\"disabled\",false); } if(ShieldJS.dialogE &amp;&amp; ShieldJS.dialogE.length &gt; 0){ ShieldJS.dialogE.find(\":button:not(.ignoredis)\").prop(\"disabled\",false); } }; //浏览器resize时调用方法 $(window).resize(function() { var actions = $.extend({},ShieldJS.winResizes); for(var actionName in actions){ try { if ($.isFunction(actions[actionName])) { actions[actionName](); } } catch (e) { ShieldJS.error(\"resize方法异常：\"+actionName+\" \"+e); return false; } } }); //document点击时调用方法，如点击空白关闭弹出层等 $(document).click(function() { var actions = $.extend({},ShieldJS.docClicks); for(var actionName in actions){ try { if ($.isFunction(actions[actionName])) { actions[actionName](); } } catch (e) { ShieldJS.error(\"点击方法异常：\"+actionName+\" \"+e); return false; } } }); × Search results Close "},"global.html":{"id":"global.html","title":"Global","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Global Members ele :jQueryObject 弹出框元素对象 Type: jQueryObject Source: shield.util.js, line 289 height :int 高度 Type: int Source: shield.util.js, line 301 index :int 下标 Type: int Source: shield.util.js, line 293 preEle :jQueryObject 上一个弹出框元素 Type: jQueryObject Source: shield.util.js, line 309 preEleIndex :jQueryObject 上一个弹出框元素下标 Type: jQueryObject Source: shield.util.js, line 305 title :String 标题 Type: String Source: shield.util.js, line 313 width :int 宽度 Type: int Source: shield.util.js, line 297 Methods dateFormat(date, format) 日期格式化（待删除，改为moment.js） Parameters: Name Type Description date Date 带格式话的日期 format String 格式化的表达式，如：yyyy-MM-dd Source: shield.util.js, line 566 Returns: Type String findAndMarkEle(ele, selector) 获取并标记获取到的元素，防止重复添加 Parameters: Name Type Description ele jQueryObject 待处理的父对象 selector String 选择器 Source: shield.util.js, line 452 See: findEle 注意区别 Returns: Type jQueryObject findAndMarkEleOn(ele, selector, events) 获取并标记元素，动态绑定事件(待完善) Parameters: Name Type Description ele jQueryObject 待处理的父对象 selector String 一个选择器字符串用于过滤器的触发事件的选择器元素的后代。如果选择的为null或省略，当它到达选定的元素，事件总是触发。 events String 一个或多个用空格分隔的事件类型和可选的命名空间，如\"click\"或\"keydown.myPlugin\" 。 Source: shield.util.js, line 484 See: findAndMarkEle 注意区别 Returns: Type jQueryObject findEle(ele, selector) 获取但不标记取到的元素 Parameters: Name Type Description ele jQueryObject 待处理的父对象 selector String 选择器 Source: shield.util.js, line 472 See: findAndMarkEle 注意区别 findAndMarkEleOn 注意区别 Returns: Type jQueryObject formatUrl(url) 格式化url，处理为标准格式的url Parameters: Name Type Description url String 待处理的url Source: shield.util.js, line 506 Returns: Type String getExtendSettings(ele, _default) 获取一个jQuery对象的扩展设置（取属性shieldSettings的设置值覆盖，不存在则取jQuery.data()设置的属性，） Parameters: Name Type Description ele jQueryObject 待处理的对象 _default Json 默认设置 Source: shield.util.js, line 368 Returns: 参数设置 Type Json getjQueryObj(selector) 根据传入字符串返回jQuery对象，如果本身为jquery对象直接返回 Parameters: Name Type Description selector Object jQuery对象或者jQuery选择器 Source: shield.util.js, line 342 Returns: jQuery对象 Type jQueryObject getJSDir() 返回当前js的目录 Source: shield.util.js, line 685 Returns: Type String getJSPath() 返回当前js的路径 Source: shield.util.js, line 666 Returns: Type String getParams(ele, params, attrName) 获取参数 Parameters: Name Type Description ele jQueryObject 待处理的对象 params Json 默认设置 attrName String 属性名 Source: shield.util.js, line 390 Returns: 参数设置 Type Json getRandomColor() 随机取色 Source: shield.util.js, line 645 Returns: 16进制表示的颜色字符串 Type String getSettings(ele, _default) 获取一个jQuery对象的设置（取属性shieldSettings的设置值） Parameters: Name Type Description ele jQueryObject 待处理的对象 _default Json 默认设置 Source: shield.util.js, line 379 Returns: 参数设置 Type Json getTimeAttr(ele, attrName, defaultValue) 获取时间参数，转换为毫秒 Parameters: Name Type Description ele jQueryObject 待处理的对象 attrName String 属性名 defaultValue Number 默认值 Source: shield.util.js, line 419 Returns: 时间值 Type Number hasAttr(jobj, attrname) 是否存在属性 Parameters: Name Type Description jobj jQueryObject 判断的对象 attrname String 属性名 Source: shield.util.js, line 356 Returns: 存在该属性则返回true，否则返回false Type Boolean jQObjEmpty2Null(ele) 判断jquery空对象转换为null，其他的原样返回 Parameters: Name Type Description ele jQueryObject 待处理的对象 Source: shield.util.js, line 627 Returns: Type jQueryObject openNewPage(ele, href, params) 打开新页面 Parameters: Name Type Description ele jQueryObject 待处理的对象 href String 超链接 params Json 参数 Source: shield.util.js, line 525 paramNameAdapt(ele) 参数名适配,返回json格式，键为源字段名值为目标字段名 Parameters: Name Type Description ele jQueryObject 待处理的对象 Source: shield.util.js, line 602 Returns: Type Map printCallStack() 打印堆栈信息 Source: shield.util.js, line 655 Returns: Type String removeHtml(str) 移除字符串中的html字符 Parameters: Name Type Description str String 待处理的字符 Source: shield.util.js, line 638 Returns: Type String replaceParamVal(oUrl, paramName, replaceWith) 替换指定传入参数的值, paramName为参数, replaceWith为新值 Parameters: Name Type Description oUrl String 待处理的url paramName String 处理参数 replaceWith String 参数处理后的值 Source: shield.util.js, line 555 Returns: Type String × Search results Close "},"classes.list.html":{"id":"classes.list.html","title":"Classes","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Classes Classes contentChange insertAtCursor resize selection serializeJson shieldBindHtmlAction shieldLeftMenu shieldMainContent Dialog Map ShieldJS ajax core dialog form HtmlAction HTMLEleActions successDo successDoMethod replaceAll Namespaces _defaults × Search results Close "},"namespaces.list.html":{"id":"namespaces.list.html","title":"Namespaces","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Namespaces Classes contentChange insertAtCursor resize selection serializeJson shieldBindHtmlAction shieldLeftMenu shieldMainContent Dialog Map ShieldJS ajax core dialog form HtmlAction HTMLEleActions successDo successDoMethod replaceAll Namespaces _defaults × Search results Close "},"index.html":{"id":"index.html","title":"Index","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth [TOC] shieldjs2框架 项目说明 富客户端框架(jQuery RIA framework)设计目标是简单实用、扩展方便、快速开发、RIA思路、轻量级；本框架支持用html扩展的方式来代替javascript代码, 只要懂html语法, 再参考使用手册就可以做ajax开发；尽量让程序员少写javascript，也能使用各种页面组件和ajax技术。如果有特定需求也可以扩展框架做定制化开发。本框架的目标是不需要开发人员去关心javascript怎么写，只要写标准html就可以了。本框架简单扩展了html标准, 给HTML定义了一些特别的 class 和 attribute 。框架会找到当前请求结果中的那些特别的 class 和 attribute, 并自动关联上相应的js处理事件和效果。; 第一次打开页面时载入界面到客户端，之后和服务器的交互只是数据交互，不占用界面相关的网络流量。 支持HTML扩展方式来调用组件。 标准化Ajax开发, 降低Ajax开发成本。 目录说明 core shieldjs2框架的核心库，必须引入，不引入不能使用; doc shieldjs2框架的说明文档; docstrap shieldjs2框架的说明文档的样式模板; depends shieldjs2框架依赖的js库，可以不引入，不引入部分功能不能使用; extends shieldjs2框架的扩展库，不需要不引入，只是做了示例，在具体实现类中扩展; impl shieldjs2框架的具体实现，必须引入，不引入不能使用大部分功能; tool shieldjs2框架包含的模块库，必须引入，不引入不能使用，可独立于该框架作为工具类使用; 命名说明 提示框 ShieldJS.alert(title, msg, type); //type字符型（success、error、info、warning） 确认框 ShieldJS.confirm(title, message, ok, cancel) data-url 链接 data-url-node 节点url，用于树形结构等 data-url-show定义新增按钮的url【非必需，没有可不填】 data-url-add定义新增按钮的url【非必需，没有可不填】 data-url-upd定义修改按钮的url【非必需，没有可不填】 data-url-del定义删除按钮的url【非必需，没有可不填】 data-target 目标对象 data-target，搜索按钮， paramSelector 参数选择器,动态参数 paramAdapter 参数适配器,适配 源字段名1&gt;目标字段名1#源字段名2[&gt;目标字段名1]，源字段名与目标字段名一致时目标字段名可省略 selectNode 选中节点,从0开始 shieldSettings 插件参数设置 data-rel-type 类型shieldDialog：iframe ，addtabs：new data-rel-id id用于区分tab等 操作列 S|U|D，R代表Show查看，U代表Update更新，D代表Delete删除可以不写值,showName用于该列title前缀【非必需】，没有时取tab标题栏的.title内容 不需要初始化的插件元素，增加样式noshield 不需要表单验证的input元素，增加样式ignore（disabled的也不进行验证） 使用说明1、绑定html动作前后的回调方法，可以增加bindBefore和bindAfter属性，属性值为方法名，建议方法名写长一些。 &lt;!-- bindAfter表示绑定完成后回调的方法，在页面事件绑定完成后执行，bindBefore是在之前 --&gt; &lt;div class=\"multi-tab_plugin\" style=\"overflow: hidden;\" bindAfter=\"addTab_191009\"&gt; &lt;div class=\"mtab-box\" &gt; &lt;ul class=\"mtab-title clearfix\"&gt; &lt;li class=\"on title\" data-url=\"${ctxPathA }/system/permission/getPermDetails\" shieldParams=\"{id:'${id }'}\"&gt;权限信息&lt;/li&gt; &lt;!-- // on 点击状态 --&gt; &lt;li class=\"title\" data-url=\"${ctxPathA }/system/permission/getHasPermRoles\" shieldParams=\"{id:'${id }'}\"&gt;拥有权限的角色&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class=\"mtab-content\"&gt; &lt;!-- //内容部分 --&gt; &lt;div class=\"mtab-item multi-show\"&gt; &lt;%@include file=\"sysperm_show_permdetail.jsp\"%&gt; &lt;/div&gt; &lt;!-- //multi-show 当前标签内容部分 --&gt; &lt;div class=\"mtab-item\" style=\"display: none;\"&gt; &lt;%@include file=\"sysperm_show_haspermroles.jsp\"%&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script type=\"text/javascript\" src=\"${ctxPath}/js/lib/jquery.contextmenu.r2.js?20190903085211\"&gt;&lt;/script&gt; &lt;script&gt; var addTab_191009 = function(ele){ // ele为绑定事件的元素 var $this = ele; alert($this.length) $this.multiTabAdd(\"test\", \"test\", \"测试\", 1, \"/software-center/a/system/permission/getHasPermRoles?a=b\", \"{id:'566578227917619200'}\"); $this.multiTabAdd(\"test\", \"test1\", \"测试1\"); $this.multiTabAdd(\"test2\", \"test2搜索\", \"测试2\"); $this.multiTabAdd(\"test3\", \"test3为\", \"测试3\"); $this.multiTabAdd(\"test4\", \"test4释放的\", \"测试4\"); $this.multiTabAdd(\"test5\", \"test5释放的\", \"测试5\"); $this.multiTabAdd(\"test6\", \"test6说法是\", \"测试6\"); $this.multiTabAdd(\"test7\", \"test7释放的\", \"测试7\"); $this.multiTabAdd(\"test8\", \"test8说法是\", \"测试8\"); } &lt;/script&gt;插件属性 插件属性采用3种方式获取 1、ShieldJS自定义属性采用“属性名=属性值”的配置方式，具体属性参考具体使用说明；&lt;!-- myname为自定义属性名 --&gt; &lt;a myname=\"test\"&gt;示例&lt;/a&gt;// 获取 ele.attr(\"myname\"); 2、本框架采用jQuery的data定义属性,大部分的配置可以采用“data-属性名”方式配置，取值时使用data(属性名)取，注意data取值默认会把属性名转换为小写，如果需要大写用“-”连接，如需要去data(\"userName\"),则需要定义为data-user-name。也支持以json格式设置到shieldSettings中；例如：（1）、需要在js中使用jQueryObject.data(\"name\")，则属性配置为data-name=\"test\";&lt;a data-name=\"test\"&gt;示例&lt;/a&gt;// 获取 ele.data(\"name\");（2）、需要在js中使用jQueryObject.data(\"nameType\")，属性配置为data-name-type=\"test\";&lt;a data-name-type=\"test\"&gt;示例&lt;/a&gt;// 获取,注意T需要为大写，反过来如果为大写的字母，属性前一定要用-连接 ele.data(\"nameType\");（3）、配置属性shieldSettings='{name:\"test\",show:false}'，框架会自动解析并传入options中。使用 getExtendSettings 获取设置的属性（包含data和shieldSettings都会获取，其中shieldSettings优先级最高）&lt;!-- 注意本例子中shieldSettings和data-name中都定义了name属性，以shieldSettings优先 --&gt; &lt;a shieldSettings='{name:\"test\",show:false}' data-name=\"myname\"&gt;示例&lt;/a&gt;// 获取 var params = {}; getExtendSettings(ele, params); 3、第三方插件的属性配置，支持以json格式设置到shieldSettings中，同上。json回调 一般要求有是否成功（success），返回信息（message），返回结果3个字段例如： { \"success\":true, \"message\":\"添加成功！\", \"data\":[{},{}] } 扩展插件如果默认提供的插件不满足要求可以对插件进行覆盖或增加新的插件 扩展插件扩展插件的2种写法： /** * @description 示例一，不带checkFn的函数 * @field * 必需： * 第一个参数为自定义html动作处理的名字，注意与已有的是否冲突，如果冲突会用新的覆盖旧的（可以用来重写方法而不改变框架原有方法） * 第二个参数为需处理的元素的jquery选择器表达式 * 第三个参数为js动作初始方法 * （均为jquery对象） * contentE:处理的内容对象，menuli：左侧栏menu，menu：导航栏menu，searchForm：搜索表单，shieldDialog：弹出框 * 第四个参数为方法描述 */ ShieldJS.HtmlAction.addHTMLEleAction(\"selfAction\", \".selfAction\", function(contentE, menuli, menu, searchForm, shieldDialog){ var dealEle = findAndMarkEle(contentE, this.expression); if (dealEle.length &gt; 0) { dealEle.unbind(\"click\").click(function(){ ShieldJS.alert(\"消息提示\", \"自定义js处理动作示例1\", \"info\"); return false; }); } },\"自定义示例一，不带checkFn的函数\"); /** * @description 示例二，带checkFn的函数 * @field * 必需： * 第一个参数为自定义html动作处理的名字，注意与已有的是否冲突，如果冲突会用新的覆盖旧的（可以用来重写方法而不改变框架原有方法） * 第二个参数为需处理的元素的jquery选择器表达式 * 第三个参数为js动作初始方法 * （均为jQuery对象） * selectE:处理的jquery对象（checkFn中返回的对象），menuli：左侧栏menu，menu：导航栏menu，searchForm：搜索表单，shieldDialog：弹出框 * 第四参数为刷新符合条件的html元素（如是否缺少相关联的父子容器或存储容器），没有符合条件的返回false，有则返回合格条件的jQuery对象 * （均为jQuery对象） * contentE:处理的页面对象，menuli：左侧栏menu，menu：导航栏menu，searchForm：搜索表单，shieldDialog：弹出框 * 第五个参数为方法描述 */ ShieldJS.HtmlAction.addHTMLEleAction(\"selfAction2\", \".selfAction2\", function(selectE, menuli, menu, searchForm, shieldDialog){ selectE.unbind(\"click\").click(function(){ ShieldJS.alert(\"消息提示\", \"自定义js处理动作示例2\", \"info\"); return false; }); }, function (contentE, menuli, menu, searchForm, shieldDialog) { var dealEle = findAndMarkEle(contentE, this.expression); if (dealEle.length &gt; 0) { // 可进一步筛选 return dealEle; //返回符合条件的jQuery对象 } return dealEle.length &gt; 0 ? dealEle : false; },\"自定义示例二，带checkFn的函数\"); 内置方法 1、获取参数 getParams(ele, params, attrName) , attrName可以不写，不写默认找shieldParams属性的定义值（json字符串） getSettings(ele, _default) 取属性shieldSettings的设置值） getExtendSettings(ele, _default) 取属性shieldSettings的设置值覆盖，不存在则取jQuery.data()设置的属性，一般用于第三方插件的扩展原插件属性。 ShieldJS.HtmlAction.checkAnGetParamSelector(ele, params, contentEle);获取动态参数，ele上定义paramSelector属性（值为jQuery选择器表达式） &lt;input id=\"export\" type=\"button\" class=\"shieldA\" shieldParams=\"{'conn':'${conn}'}\" paramSelector=\":checkbox[name='tableName']\" data-method=\"post\" data-url=\"${ctxPathA}/system/outdatabase/toOutWord\" value=\"导出Word表结构\"/&gt; &lt;input type=\"checkbox\" name=\"tableName\" value=\"name1\"/&gt; &lt;input type=\"checkbox\" name=\"tableName\" value=\"name2\"/&gt; &lt;javascript&gt; var ele = $(\"#export\"); // 第三个参数contentEle表示查询参数的范围，不写默认查内容页 ShieldJS.HtmlAction.checkAnGetParamSelector(ele, params); &lt;/javascript&gt; 版本说明v2.0.0（2018-08-13） 初版，在原来内部使用的框架基础上改造为通用框架; × Search results Close "},"$().contentChange.html":{"id":"$().contentChange.html","title":"Class: contentChange","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: contentChange contentChange new contentChange(selector, callbackFn) 动态监听内容变化 Parameters: Name Type Description selector String jQuery选择器 callbackFn function 回调函数 Author: kevin Lv Source: shield.util.js, line 28 Example $(\"body\").contentChange(\"body\", function(){}); × Search results Close "},"$().insertAtCursor.html":{"id":"$().insertAtCursor.html","title":"Class: insertAtCursor","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: insertAtCursor insertAtCursor new insertAtCursor(myValue) 将值插入到光标位置 Parameters: Name Type Description myValue String 赋值 Author: 来自网络 Source: shield.util.js, line 121 Example $(\"#div1\").insertAtCursor('123'); × Search results Close "},"$().resize.html":{"id":"$().resize.html","title":"Class: resize","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: resize resize new resize(callbackFn) resize增强版（默认只有浏览器窗口调整大小，修改后可监听div或其它元素） Parameters: Name Type Description callbackFn function 回调函数 Author: 来自网络 Source: shield.util.js, line 49 Example $(\"#div1\").resize(function(){}); × Search results Close "},"$().selection.html":{"id":"$().selection.html","title":"Class: selection","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: selection selection new selection() 获取选中元素对象（对象中包含开始位置、结束位置、内容） Author: 来自网络 Source: shield.util.js, line 152 Example $(\"#div1\").selection().text; × Search results Close "},"$().serializeJson.html":{"id":"$().serializeJson.html","title":"Class: serializeJson","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: serializeJson serializeJson new serializeJson() 序列表单内容为json对象 Author: kevin Lv Source: shield.util.js, line 3 Returns: json对象 Type Json Example $(\"form\").serializeJson() × Search results Close "},"$().shieldBindHtmlAction.html":{"id":"$().shieldBindHtmlAction.html","title":"Class: shieldBindHtmlAction","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: shieldBindHtmlAction shieldBindHtmlAction new shieldBindHtmlAction(options) 页面HTML元素处理（绑定HTML处理，只在页面上邦迪html处理，如果包含tab则使用上面的方法） Parameters: Name Type Description options json 配置参数,topBarE为topBar元素或者对应的选择器,topMenu头部导航栏对应的menu元素或者对应的选择器,searchForm为搜索表单元素或者对应的选择器，dialog为弹出框对象(类型为ShieldJS.dialog) Since: version 1.0 Author: kevin Lv Source: shield.core.js, line 882 Example $(\"#content\").shieldBindHtmlAction(); //带参数的用法 topBarE为topBar元素或者对应的选择器,topMenu头部导航栏对应的menu元素或者对应的选择器,searchForm为搜索表单元素或者对应的选择器，dialog为弹出框对象(类型为ShieldJS.dialog) $(\"#content\").shieldBindHtmlAction({leftMenu:'#leftMenu',topMenu:'#topMenu',searchForm:'.sarchForm',dialog:dialog}); × Search results Close "},"$().shieldLeftMenu.html":{"id":"$().shieldLeftMenu.html","title":"Class: shieldLeftMenu","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: shieldLeftMenu shieldLeftMenu new shieldLeftMenu(options) 左侧菜单处理，并处理内容区 Parameters: Name Type Description options json 配置参数,参考ShieldJS.core._defaults, topMenuClickEle头部导航栏对应的菜单选项 Since: version 1.0 Author: kevin Lv Source: shield.core.js, line 927 Example $(\"#content\").shieldLeftMenu(); //带参数的用法 topMenuClickEle头部导航栏对应的菜单选项 $(\"#content\").shieldLeftMenu({topBarE:'#topBar',topMenuE:'#navMenu'}); × Search results Close "},"$().shieldMainContent.html":{"id":"$().shieldMainContent.html","title":"Class: shieldMainContent","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: shieldMainContent shieldMainContent new shieldMainContent(options) 初始化页面HTML元素处理（与$.fn.shieldBindHtmlAction方法代码类似，区别在于本方法处理多页签，包含form回调方法） Parameters: Name Type Description options json 配置参数 Since: version 1.0 Author: kevin Lv Source: shield.core.js, line 955 Example $(\"#content\").shieldMainContent(); //带参数的用法 leftMenuClickE为左侧栏选中的菜单，topMenuClickEle为头部菜单选中的菜单 $(\"#content\").shieldMainContent({leftMenuClickE:'#leftMenu',topMenuClickEle:'#topMenu'}); × Search results Close "},"Dialog.html":{"id":"Dialog.html","title":"Class: Dialog","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: Dialog Dialog new Dialog() Dialog对象 Author: kevin Lv Source: shield.util.js, line 276 Example 示例： var dialog = new Dialog(); dialog.put(ele, index, width, height, preEle, preEleIndex); × Search results Close "},"Map.html":{"id":"Map.html","title":"Class: Map","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: Map Map new Map() Map对象 Author: kevin Lv Source: shield.util.js, line 186 Example 示例： var myMap = new Map(); myMap.put(\"key\",\"value\"); var key = myMap.get(\"key\"); myMap.remove(\"key\"); × Search results Close "},"ShieldJS.html":{"id":"ShieldJS.html","title":"Class: ShieldJS","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: ShieldJS ShieldJS new ShieldJS() ShieldJS主类，定义了框架的一些主要属性及方法 Version: 2.1.0 Author: Kevin Lv Source: shield.main.js, line 8 Classes ajax core dialog form HtmlAction Members &lt;static, readonly&gt; _msg :Key-Value 框架消息模板 Type: Key-Value Source: shield.main.js, line 47 &lt;static, readonly&gt; _set :Boolean 内部变量设置（可设置是否调试模式） Type: Boolean Properties: Name Type Default Description debug Boolean true 调试模式，部署时关闭 Source: shield.main.js, line 66 &lt;static&gt; activeSiderE :jQueryObject 左侧栏选中区 Type: jQueryObject Source: shield.main.js, line 848 &lt;static&gt; activeTabTitleE :jQueryObject 当前可见的主内容区tab标题 Type: jQueryObject Source: shield.main.js, line 860 &lt;static&gt; activeTopMenuE :jQueryObject 选中的头部菜单区 Type: jQueryObject Source: shield.main.js, line 840 &lt;static&gt; avtiveTabContentE :jQueryObject 当前可见的主内容区tab内容区 Type: jQueryObject Source: shield.main.js, line 856 &lt;static&gt; contentMainE :jQueryObject 主内容区（不变） Type: jQueryObject Source: shield.main.js, line 852 &lt;static, readonly&gt; css :String 框架内置的几种常用样式名 Type: String Properties: Name Type Default Description TITLE String viewTitle WIDTH String viewWidth HEIGHT String viewHeight SHOW String shield-show 显示 THIS String shield-this 选中 DISABLED String shield-disabled 禁用 Source: shield.main.js, line 28 &lt;static&gt; debugTrace 调试输出是否输出堆栈信息 Source: shield.main.js, line 73 &lt;static&gt; dialogE :jQueryObject 弹出框 ，其他可在实现框架内扩展 Type: jQueryObject Source: shield.main.js, line 864 &lt;static&gt; dialogs :Map 弹出框Map,key为下标，value为dialog对象 Type: Map Source: shield.main.js, line 674 &lt;static&gt; docClicks :Key-Value document点击的处理事件集合（使用时 docClicks[\"方法名\"]=function） Type: Key-Value Source: shield.main.js, line 442 &lt;static&gt; jsPath :String 当前js文件的路径，通过ShieldJS.getJsPath获取 Type: String Source: shield.main.js, line 132 See: ShieldJS.getJsPath &lt;static, readonly&gt; keyCode :int 键盘按键的值的常量 Type: int Properties: Name Type Default Description ENTER int 13 ESC int 27 END int 35 HOME int 36 SHIFT int 16 TAB int 9 BLANK int 32 LEFT int 37 RIGHT int 39 UP int 38 DOWN int 40 DELETE int 46 BACKSPACE int 8 Source: shield.main.js, line 18 &lt;static&gt; loadingHtml :String 加载中的html代码 Type: String Source: shield.main.js, line 828 &lt;static&gt; shieldDialogCallback :Key-Value shieldDialog回调方法 Type: Key-Value Source: shield.main.js, line 868 &lt;static&gt; siderE :jQueryObject 左侧栏 Type: jQueryObject Source: shield.main.js, line 844 &lt;static&gt; topBarE :jQueryObject 头部信息区 Type: jQueryObject Source: shield.main.js, line 832 &lt;static&gt; topMenuE :jQueryObject 头部菜单区 Type: jQueryObject Source: shield.main.js, line 836 &lt;static, constant&gt; version :String ShieldJS的版本号 Type: String Source: shield.main.js, line 13 &lt;static&gt; winResizes :Key-Value 窗口resize的处理事件集合（使用时 winResizes[\"方法名\"]=function） Type: Key-Value Source: shield.main.js, line 438 Methods &lt;static&gt; alert(title, message, type) 提示框，可以覆盖，默认采用alert，type字符型（success、error、info、warning） Parameters: Name Type Description title String 标题 message String 提示内容 type String 提示类型包括：success、error、info、warning4种 Source: shield.main.js, line 147 &lt;static&gt; checkError(data, contentType) 返回值统一方法，判断有无错误（TODO方法名待修改） Parameters: Name Type Description data Object 验证对象，可能为json对象也可能为html文本，json对象示例{\"success\":true,\"message\":\"提示信息\"} contentType String 返回结果类型 Source: shield.main.js, line 364 Returns: 验证通过时返回true，否则返回false Type Boolean &lt;static&gt; checkErrorLoginExtend(data, data) 检查返回数据登录的扩展方法（子类可覆盖） Parameters: Name Type Description data JSON 返回的对象，一般为json格式 data Object 返回的原始对象，一般为string或者json格式 Source: shield.main.js, line 410 Returns: 返回true继续执行后续方法，返回false则不再执行后续方法 Type Boolean &lt;static&gt; confirm(title, message, ok, cancel) 确认框 Parameters: Name Type Description title String 标题 message String 提示内容 ok String 确定后的回调方法 cancel String 取消后的回调方法 Source: shield.main.js, line 155 &lt;static&gt; debug(msg, trace) 调试输出 Parameters: Name Type Description msg String 调试信息 trace Boolean 输出堆栈信息 Source: shield.main.js, line 78 &lt;static&gt; error(msg) 错误输出 Parameters: Name Type Description msg String 错误信息 Source: shield.main.js, line 99 &lt;static&gt; getJsPath() 获取当前js文件的路径 Source: shield.main.js, line 136 See: ShieldJS.jsPath Returns: 当前js文件的路径 Type String &lt;static&gt; init(options) 初始化方法，使用时直接调用该方法 Parameters: Name Type Description options 配置文件，参考shield.core.js的参数配置 Source: shield.main.js, line 879 See: shield.core.js#_defaults &lt;static&gt; initExtend(options) 初始化扩展方法 Parameters: Name Type Description options 配置文件，参考shield.core.js的参数配置 Source: shield.main.js, line 873 See: shield.core.js#_defaults &lt;static&gt; loadfile(path, success) 加载文件 Parameters: Name Type Description path String 文件路径 success function 加载成功后的回调方法 Source: shield.main.js, line 116 &lt;static&gt; msg(key, args) 根据key及传入参数获取模板信息 Parameters: Name Type Description key String 内置消息模板的key args Array(Object) 替换模板变量的参数 Source: shield.main.js, line 52 Returns: 替换参数后的模板信息 Type String &lt;static&gt; openDialog(url, params, callback, title, width, height, async, relType, options) 打开弹出框(实际调用的是dialog.open) Parameters: Name Type Description url String 弹出框的链接 params Object 参数,json格式或者字符串格式 callback function 打开弹出框后的回调 title String 弹出框标题 width Number 弹出框宽度 height Number 弹出框高度 async Boolean 是否异步 relType String 关联类型，可以为iframe或者不填 options Json 扩展属性 Source: shield.main.js, line 686 &lt;static&gt; setVersion(suffix) 设置ShieldJS的版本号 Parameters: Name Type Description suffix String 版本号后缀 Source: shield.main.js, line 105 × Search results Close "},"ShieldJS.ajax.html":{"id":"ShieldJS.ajax.html","title":"Class: ajax","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: ajax ShieldJS. ajax new ajax() 框架封装的ajax方法 Source: shield.main.js, line 162 Members &lt;static&gt; global ajax全局处理方法，可覆盖 Source: shield.main.js, line 182 &lt;static&gt; requests ajax请求对象 Source: shield.main.js, line 166 Methods &lt;static&gt; ajax(ele, url, params, success, error, method, dataType, async) ajax请求 Parameters: Name Type Description ele jQueryObj 发起请求的jQuery对象 url String 请求链接 params Object 参数,json格式或者字符串格式 success function 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 error function 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 method String 请求方法 dataType String 返回结果类型 async Boolean 是否是异步请求 Source: shield.main.js, line 246 &lt;static&gt; get(ele, url, params, success, error, dataType, async) ajax发起get请求 Parameters: Name Type Description ele jQueryObj 发起请求的jQuery对象 url String 请求链接 params Object 参数,json格式或者字符串格式 success function 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 error function 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 dataType String 返回结果类型，参考jQuery的ajax说明 async Boolean 是否是异步请求 Source: shield.main.js, line 335 &lt;static&gt; getJSON(url, params, success, error, async) ajax获取json对象 Parameters: Name Type Description url String 请求链接 params Object 参数,json格式或者字符串格式 success function 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 error function 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 async Boolean 是否是异步请求 Source: shield.main.js, line 355 &lt;static&gt; post(ele, url, params, success, error, dataType, async) ajax发起post请求 Parameters: Name Type Description ele jQueryObj 发起请求的jQuery对象【非必需】 url String 请求链接 params Object 参数,json格式或者字符串格式 success jQueryObj 成功的回调方法，注意区别于ajax原生的success，该方法为后台返回的成功方法 error jQueryObj 失败的回调方法，注意区别于ajax原生的error，该方法为后台返回的失败方法 dataType jQueryObj 返回结果类型，参考jQuery的ajax说明 async jQueryObj 是否是异步请求 Source: shield.main.js, line 346 × Search results Close "},"ShieldJS.core.html":{"id":"ShieldJS.core.html","title":"Class: core","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: core ShieldJS. core new core() 框架核心方法 Source: shield.main.js, line 37 Namespaces _defaults Members &lt;static&gt; options :json 初始化之后的参数 Type: json Author: 吕凯 Source: shield.core.js, line 26 Methods &lt;static&gt; bindHtmlAction(methodNames, contentE, menuliSelectE, topMenuSelectE, searchForm, shieldDialog) 绑定Html动作处理 Parameters: Name Type Description methodNames Array 调用方法名，字符串数组，【非必需】，不写则调用全部方法 contentE jQueryObject 内容dom【必需】jQuery对象 menuliSelectE jQueryObject 左侧栏选中的menu【非必需】jQuery对象 topMenuSelectE jQueryObject 导航栏选中的menu【非必需】jQuery对象 searchForm jQueryObject 搜索表单【非必需】jQuery对象 shieldDialog ShieldJS.dialog 弹出框对象【非必需】shieldDialog对象 Author: 吕凯 Source: shield.core.js, line 41 &lt;static&gt; contentAreaDeal(contentE, siderMenuClickEle, topMenuSelectE) 页面框架化处理：：：处理整个内容区 Parameters: Name Type Description contentE jQueryObject 内容dom【必需】（以下均为jquery对象） siderMenuClickEle jQueryObject 左侧栏选中的menu【非必需】 topMenuSelectE jQueryObject 头部导航栏选中的menu【非必需】 Author: 吕凯 Source: shield.core.js, line 117 &lt;static&gt; initLeftCommonMenu(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect) 左侧栏初始化::普通菜单的处理，一般为ul&gt;li Parameters: Name Type Description liMenuContainerE jQueryObject 左侧菜单栏普通菜单对象容器 siderE jQueryObject 左侧菜单栏容器对象 topBarE jQueryObject 头部bar topMenuClickEle jQueryObject 当前选中的头部菜单 setDefaultSelect Boolean 是否设定默认选中项 Source: shield.core.js, line 266 &lt;static&gt; initLeftExtendMenu(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect) 左侧栏初始化::扩展菜单（空方法，用于框架扩展） Parameters: Name Type Description liMenuContainerE jQueryObject 左侧菜单栏普通菜单对象 siderE jQueryObject 左侧菜单栏容器对象 topBarE jQueryObject 头部bar topMenuClickEle jQueryObject 当前选中的头部菜单 setDefaultSelect Boolean 是否设定默认选中项 Source: shield.core.js, line 610 &lt;static&gt; initLeftLazyMenu(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect) 左侧栏初始化::懒加载菜单的处理 Parameters: Name Type Description liMenuContainerE jQueryObject 左侧菜单栏普通菜单对象 siderE jQueryObject 左侧菜单栏容器对象 topBarE jQueryObject 头部bar topMenuClickEle jQueryObject 当前选中的头部菜单 setDefaultSelect Boolean 是否设定默认选中项 Source: shield.core.js, line 551 &lt;static&gt; initLeftMenu(siderE, topBarE, topMenuClickEle, setDefaultSelect) 左侧栏初始化，内置了3中菜单处理，1、普通菜单（选择器.shield-menus，方法ShieldJS.core.initLeftCommonMenu）2、树形菜单（选择器.shieldZTreeMenu,方法ShieldJS.core.initLeftZtreeMenu） 3、懒加载菜单（选择器.shieldLazyMenu,方法ShieldJS.core.initLeftExtendMenu）以上三个方法的默认实现如果不满足实际使用可以覆盖对应的方法，如果不在这三种里可以扩展（ShieldJS.core.initLeftExtendMenu） Parameters: Name Type Description siderE jQueryObject 左侧菜单栏对象 topBarE jQueryObject 头部bar topMenuClickEle jQueryObject 当前选中的头部菜单 setDefaultSelect Boolean 是否设定默认选中项 Source: shield.core.js, line 239 &lt;static&gt; initLeftZtreeMenu(liMenuContainerE, siderE, topBarE, topMenuClickEle, setDefaultSelect) 左侧栏初始化::树形菜单的处理，默认采用ztree Parameters: Name Type Description liMenuContainerE jQueryObject 左侧菜单栏普通菜单对象容器 siderE jQueryObject 左侧菜单栏容器对象 topBarE jQueryObject 头部bar topMenuClickEle jQueryObject 当前选中的头部菜单 setDefaultSelect Boolean 是否设定默认选中项 Source: shield.core.js, line 381 &lt;static&gt; initMainPage(topBarE, topMenuE) 页面框架化处理：：：主页面操作 默认实现如果不满足实际使用可以覆盖对应的方法 Parameters: Name Type Description topBarE jQueryObject 头部bar，用于与内容页的交互跳转 topMenuE jQueryObject 头部菜单 Source: shield.core.js, line 132 &lt;static&gt; leftCommonMenuClickDoing(event, liMenuContainerE, siderMenuClickEle, contentMainE) 左侧普通菜单栏点击事件::普通菜单的处理，一般为ul&gt;li Parameters: Name Type Description event Event 事件对象 liMenuContainerE jQueryObject 左侧菜单栏普通菜单对象容器 siderMenuClickEle jQueryObject 左侧菜单点击的菜单对象 contentMainE jQueryObject 内容区 Source: shield.core.js, line 370 &lt;static&gt; main(options) 主函数，可直接调用，建议通过ShieldJS.init调用 Parameters: Name Type Description options json 配置参数ShieldJS.core._defaults Author: 吕凯 Source: shield.core.js, line 8 × Search results Close "},"ShieldJS.core._defaults.html":{"id":"ShieldJS.core._defaults.html","title":"Namespace: _defaults","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Namespace: _defaults ShieldJS.core. _defaults 私有变量，框架的默认配置，外部不可见 Properties: Name Type Description topBarE String/jQueryObj 头部信息区（jQuery对象或选择器） topMenuE String/jQueryObj 头部菜单区（jQuery对象或选择器） siderE String/jQueryObj 左侧栏（jQuery对象或选择器） contentMainE String/jQueryObj 主内容区（jQuery对象或选择器） contentNavTabE String/jQueryObj 主内容区navTab（jQuery对象或选择器） contentActiveTabE String/jQueryObj 主内容区当前活动Tab（jQuery对象或选择器） navMenuCurClass String 内容区多页签选项卡选中的样式 headerCurClass String 内容区多页签选项卡选中的样式 liMenuCurClass String 左侧菜单选中的样式 bindHtmlErrorCallback String html绑定失败回调方法(actionName, e) bindHtmlSuccCallback String html绑定成功回调方法 bindHtmlCallback String html绑定完成回调方法（成功失败都会调用） templPath String 模板路径，不填找templ目录下的文件，自定义目录时文件名需要保持一致 Source: shield.core.js, line 616 × Search results Close "},"ShieldJS.dialog.html":{"id":"ShieldJS.dialog.html","title":"Class: dialog","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: dialog ShieldJS. dialog new dialog() 弹出层，依赖于layer js Source: shield.main.js, line 443 Example 示例： var dialog = new ShieldJS.dialog(); dialog.index = 1; dialog.remove(); Members &lt;static&gt; dialogO :jQueryObject 弹出框元素对象 Type: jQueryObject Source: shield.main.js, line 453 Methods &lt;static&gt; open(url, params, callback, title, width, height, async, relType, options) 打开弹出框 Parameters: Name Type Description url String 弹出框的链接 params Object 参数,json格式或者字符串格式 callback function 打开弹出框后的回调 title String 弹出框标题 width Number 弹出框宽度 height Number 弹出框高度 async Boolean 是否异步 relType String 关联类型，可以为iframe或者不填 options Json 扩展属性 Source: shield.main.js, line 531 &lt;static&gt; remove() 移除弹出框 Source: shield.main.js, line 462 &lt;static&gt; resize() 重置宽高 Source: shield.main.js, line 497 × Search results Close "},"ShieldJS.form.html":{"id":"ShieldJS.form.html","title":"Class: form","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: form ShieldJS. form new form() 框架的form处理 Source: shield.main.js, line 699 Methods &lt;static&gt; initOneSubmit(formE, callback, checkFn) 初始化单个表单 Parameters: Name Type Description formE jQueryObj form标签的jQuery格式对象 callback function 表单提交后的回调 checkFn function 对表单进行检查筛选，返回true表示通过 Source: shield.main.js, line 721 &lt;static&gt; initOneSubmitExtend(formE, target) 初始化单个表单的扩展方法（默认将当前页码设置为1） Parameters: Name Type Description formE jQueryObj form标签的jQuery格式对象 target String 表单提交后目标对象 Source: shield.main.js, line 808 &lt;static&gt; initSubmit(ele, callback, checkFn) 初始化当前元素的表单 Parameters: Name Type Description ele jQueryObj 需要处理的jQuery对象 callback function 表单提交后的回调 (formE, targetE, data) checkFn function 对表单进行检查筛选，返回true表示通过 Source: shield.main.js, line 707 &lt;static&gt; validate(formE) 表单验证 Parameters: Name Type Description formE jQueryObj 待验证的form对象 Source: shield.main.js, line 819 Returns: 验证通过时返回true，否则返回false Type Boolean × Search results Close "},"ShieldJS.HtmlAction.html":{"id":"ShieldJS.HtmlAction.html","title":"Class: HtmlAction","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: HtmlAction ShieldJS. HtmlAction new HtmlAction() 框架html动作绑定方法 Source: shield.main.js, line 40 Classes HTMLEleActions successDo successDoMethod Methods &lt;static&gt; addHTMLEleAction(HTMLEleName, expression, fn, checkFn, description) 添加htmlEle动作处理函数 Parameters: Name Type Description HTMLEleName String 方法名称 expression String 表单式 fn String 处理函数 checkFn String 检查函数【可无】 description String 方法描述 Source: shield.HtmlAction.js, line 1241 &lt;static&gt; checkSuccessDoMethodExist(successDoName) 检查成功的回调函数是否存在 Parameters: Name Type Description successDoName String 成功后的回调方法名 Source: shield.HtmlAction.js, line 95 Returns: 方法存在时返回true，否则返回false Type Boolean &lt;static&gt; execSuccessDoMethod(successDoName) 指定成功的回调函数,result为成功返回的结果 Parameters: Name Type Description successDoName String 成功后的回调方法名 Source: shield.HtmlAction.js, line 107 &lt;static&gt; formSubmitCallback(successDo, formE, targetE, data, menuliSelect, navMenuSelect, searchForm, dialog) 表单提交成功后的回调方法 Parameters: Name Type Description successDo String 成功后的回调方法名 formE jQuery 表单对象 targetE jQuery 表单提交的目标对象 data Object 返回结果的对象可能为json也可能为页面字符 menuliSelect jQuery 左侧栏menu navMenuSelect jQuery 导航栏menu searchForm jQuery 搜索表单 dialog ShieldJS.dialog 弹出框对象 Source: shield.HtmlAction.js, line 259 × Search results Close "},"ShieldJS.HtmlAction.HTMLEleActions.html":{"id":"ShieldJS.HtmlAction.HTMLEleActions.html","title":"Class: HTMLEleActions","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: HTMLEleActions ShieldJS.HtmlAction. HTMLEleActions new HTMLEleActions() html元素的扩展动作方法 Source: shield.HtmlAction.js, line 286 Members &lt;static&gt; autoSubmitFormPlugin 用于表单自动提交 Source: shield.HtmlAction.js, line 1135 &lt;static&gt; checkall 全选 Source: shield.HtmlAction.js, line 1097 &lt;static&gt; noDataTrPlugin 无数据tr处理 Source: shield.HtmlAction.js, line 1154 &lt;static&gt; shieldA a标签附加参数(如果不是新打开的页面,为Get方式提交需要注意参数长度) Source: shield.HtmlAction.js, line 566 &lt;static&gt; shieldAjax ajax请求,返回json格式，删除、更新状态等 Source: shield.HtmlAction.js, line 413 &lt;static&gt; shieldCheckedRelated 关联其他元素的checkbox或radio Source: shield.HtmlAction.js, line 975 Example // shieldCheckedRelated关联操作checkbox或radio元素，relatedTo为关联到的元素，relatedToType=\"disabled\"表示将目标元素更改disabled属性（其他值：disabledAndHide及不写） &lt;sapn style=\"float: left;padding: 3px;\"&gt;&lt;input type=\"checkbox\" id=\"acceptSetBtn\" class=\"shieldCheckedRelated\" relatedTo=\"#buySubmit\" relatedToType=\"disabled\"&gt;我已阅读并接受此规定&lt;/sapn&gt; &lt;input type=\"button\" id=\"buySubmit\" class=\"shieldSubmit\" value=\"购买\" disabled=\"disabled\"&gt; &lt;static&gt; shieldDelete ajax删除的处理 Source: shield.HtmlAction.js, line 466 &lt;static&gt; shieldDialogCallback 回调 Source: shield.HtmlAction.js, line 733 &lt;static&gt; shieldDialogOrLookup 弹出窗口，添加，显示，修改等；查找带回 Source: shield.HtmlAction.js, line 291 &lt;static&gt; shieldDownload 下载附件 Source: shield.HtmlAction.js, line 843 &lt;static&gt; shieldImageUpload 图片上传 Source: shield.HtmlAction.js, line 804 &lt;static&gt; shieldImgDelete 删除图片 Source: shield.HtmlAction.js, line 817 &lt;static&gt; shieldLoad 覆盖内容，类似于jQuery的jObj.load() Source: shield.HtmlAction.js, line 483 &lt;static&gt; shieldMultiImgUpload 多图片上传插件 Source: shield.HtmlAction.js, line 830 &lt;static&gt; shieldOpenLink 打开链接 Source: shield.HtmlAction.js, line 619 &lt;static&gt; shieldOpenWindow 弹出新窗口操作 Source: shield.HtmlAction.js, line 745 &lt;static&gt; shieldRefresh 刷新 Source: shield.HtmlAction.js, line 684 &lt;static&gt; shieldSelectRelated 关联其他元素的select Source: shield.HtmlAction.js, line 864 Example //选择1时显示 id为dealBySpider的元素 选择2是显示id为yaunyinSpider的元素 &lt;select id=\"state\" name=\"state\" class=\"shieldSelectRelated\"&gt; &lt;option value=\"\"&gt;--请选择--&lt;/option&gt; &lt;option value=\"1\" relatedTo=\"#dealBySpider\"&gt;通过&lt;/option&gt; &lt;option value=\"2\" relatedTo=\"#yaunyinSpider\"&gt;退回&lt;/option&gt; &lt;/select&gt; &lt;static&gt; shieldSelectRow 用于标记选中行，一般用于checkbox上用于选中行传参 Source: shield.HtmlAction.js, line 1121 &lt;static&gt; shieldSubmit 带参数提交（form基础上点击不同按钮提交不同结果） Source: shield.HtmlAction.js, line 697 &lt;static&gt; showAllShieldJS 用于显示所有已经注册的ShieldJS的html扩展动作方法 Source: shield.HtmlAction.js, line 1166 × Search results Close "},"ShieldJS.HtmlAction.successDo.html":{"id":"ShieldJS.HtmlAction.successDo.html","title":"Class: successDo","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: successDo ShieldJS.HtmlAction. successDo new successDo() 处理成功后的回调方法名 Source: shield.HtmlAction.js, line 4 Members &lt;static&gt; shieldDialogRemove :String 只关闭dialog Type: String Source: shield.HtmlAction.js, line 18 &lt;static&gt; shieldDonothing :String 什么都不做 Type: String Source: shield.HtmlAction.js, line 12 &lt;static&gt; shieldExtend :String 自定义方法 Type: String Source: shield.HtmlAction.js, line 27 &lt;static&gt; shieldRefresh :String 刷新，关闭dialog，并刷新搜索表单(默认) Type: String Source: shield.HtmlAction.js, line 9 &lt;static&gt; shieldRefreshTab :String 刷新Tab（有dialog也会关闭）,用于多页签内容页的刷新 Type: String Source: shield.HtmlAction.js, line 21 &lt;static&gt; shieldRefreshTabIgnoreDialog :String 刷新Tab（不关闭dialog）,用于多页签内容页的刷新 Type: String Source: shield.HtmlAction.js, line 24 &lt;static&gt; shieldReSearch :String 只刷新搜索表单 Type: String Source: shield.HtmlAction.js, line 15 × Search results Close "},"ShieldJS.HtmlAction.successDoMethod.html":{"id":"ShieldJS.HtmlAction.successDoMethod.html","title":"Class: successDoMethod","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: successDoMethod ShieldJS.HtmlAction. successDoMethod new successDoMethod() 处理成功后的回调执行方法 Source: shield.HtmlAction.js, line 33 × Search results Close "},"String.replaceAll.html":{"id":"String.replaceAll.html","title":"Class: replaceAll","body":" ShieldJS2 Namespaces ShieldJS.core._defaults Classes $().contentChange$().insertAtCursor$().resize$().selection$().serializeJson$().shieldBindHtmlAction$().shieldLeftMenu$().shieldMainContentDialogMapShieldJSShieldJS.ajaxShieldJS.coreShieldJS.dialogShieldJS.formShieldJS.HtmlActionShieldJS.HtmlAction.HTMLEleActionsShieldJS.HtmlAction.successDoShieldJS.HtmlAction.successDoMethodString.replaceAll Global dateFormatelefindAndMarkElefindAndMarkEleOnfindEleformatUrlgetExtendSettingsgetjQueryObjgetJSDirgetJSPathgetParamsgetRandomColorgetSettingsgetTimeAttrhasAttrheightindexjQObjEmpty2NullopenNewPageparamNameAdaptpreElepreEleIndexprintCallStackremoveHtmlreplaceParamValtitlewidth Class: replaceAll replaceAll new replaceAll(s1, s2) 全部替换，默认替换只替换第1个 Parameters: Name Type Description s1 String 替换前字符串 s2 String 替换后字符串 Source: shield.util.js, line 434 Returns: Type String × Search results Close "}}
    </script>

    <script type="text/javascript">
        $(document).ready(function() {
            Searcher.init();
        });

        $(window).on("message", function(msg) {
            var msgData = msg.originalEvent.data;

            if (msgData.msgid != "docstrap.quicksearch.start") {
                return;
            }

            var results = Searcher.search(msgData.searchTerms);

            window.parent.postMessage({"results": results, "msgid": "docstrap.quicksearch.done"}, "*");
        });
    </script>
</body>
</html>
